Questions tagged [excel]

Microsoft Excel is a commercial spreadsheet application written and distributed by Microsoft.

Filter by
Sorted by
Tagged with
28 votes
2 answers
922 views

Life is a Game - Play it

I haven't made a game in Excel yet, so I decided to Make Conway's Game of Life. If you wish to play along, I've uploaded the workbook here. Right now it's very rudimentary (No user interface, no ...
user avatar
  • 8,800
27 votes
3 answers
1k views

Racetrack in... VBA?

So, I took a look at the August Challenge: The top-voted answer is Racetrack1: "In the game of Racetrack2, cars race around a track bounded by two concentric closed loops drawn on a ...
user avatar
  • 7,109
26 votes
9 answers
1k views

Exporting information on a collection of books to Excel

I have the following code that loops through a collection of objects and dumps different properties out to Excel. The whole j++ on every other line doesn't seem ...
user avatar
  • 411
26 votes
0 answers
661 views

Pacman implemented in OOP VBA

What?, Why? I have been inspired by several other posts on the topic of OOP implementations in VBA to try and create a Pacman clone. I think this task is not all that hard in most languages; but, I ...
user avatar
23 votes
1 answer
371 views

ABAP Excel data analyzer

I wrote this code many years ago to analyze Excel data coming in from the clipboard. Please review for performance and maintainability concerns. One minor note, from an OO perspective, a class level ...
user avatar
  • 32.5k
21 votes
1 answer
25k views

Snake in Excel in... VBA?

snake-game is a game where you control a snake in an enclosed square without running into the walls or your own body. The snake grows when you run into whatever item you are supposed to run into. My ...
user avatar
  • 7,109
20 votes
1 answer
5k views

Importing data from an external EXCEL-Sheet

I was assigned the task of copying some subsums from a given EXCEL-Sheet into the executing EXCEL-Sheet. This had to be done with an EXCEL-Macro, so non-programmers can easily use it. There was the ...
user avatar
  • 25k
19 votes
2 answers
386 views

Randomizing Civilization 5 team choice

This macro is made to randomly draw specific number of civilization choices for a specific number of Civ V players. It is based on a list of 43 possibilities and the ...
user avatar
18 votes
0 answers
255 views

Progress Bar for Excel

Any future updates can be found at Excel-VBA-ProgressBar What I've been using so far For the last 6 years I've been using a progress form which I wrote in VBA using just Windows API calls. The code (...
user avatar
17 votes
7 answers
320k views

Assigning value to cells with Excel VBA

I have an Excel Worksheet consisting of two columns, one of which is filled with strings and the other of which is empty. I would like to use VBA to assign the value of the cells in the empty column ...
user avatar
  • 171
15 votes
2 answers
24k views

Creating Excel document is very slow

Attached is a generic code I wrote to create an Excel file with x number of worksheets. The problem I am having is that it's pretty slow, like 5 seconds a sheet. It was my understanding that using a <...
user avatar
  • 829
15 votes
1 answer
172 views

Module for implementation in multiple version-controlled spreadsheets

So I maintain a large number of spreadsheets which are stored on a version-controlled server. In each spreadsheet maintained on this server there is a module containing the following code, which is ...
user avatar
  • 253
14 votes
2 answers
3k views

Avoiding repeated code in worksheet

Can someone help me make this code more professional? I'm trying my best to find something similar, but I wasn't successful. I want to avoid the repeat of the code for every single value and also I ...
user avatar
14 votes
3 answers
22k views

Validating Excel file columns

I'm looking for ways to improve this code (more readable, less redundant and maybe cleaner/faster). The problem I needed to solve: I was designated to implement a software that is going to validate ...
user avatar
  • 143
14 votes
1 answer
2k views

Template UserForm Input - launch, input, validation, error handling

I'm building a template [Process-Tracker] spreadsheet. The idea is that, for any process where we can define what steps should occur in what order (and preferably, how far apart), there will be a ...
user avatar
  • 8,800
14 votes
1 answer
117k views

Reading data from Excel sheet with ExcelDataReader

Objective: I want to import an Excel file, and read the rows of certain columns. For this, I use ExcelDataReader. I've implemented a low-level class called ...
user avatar
13 votes
1 answer
2k views

VBA Class to persist and restore Excel Application properties

Very often on Stack Overflow, and even on Code Review, I've seen questions and answers that have code that begins by persisting Excel properties like DisplayAlerts ...
user avatar
  • 1,961
13 votes
1 answer
806 views

Tick. Tick. *breathe* BOOM! - Setting up real, stable asynchronous callbacks with WinAPI Timers in VBA

WinAPI Timers can be quite tricky to work with, as anyone who's tried to use them and fallen foul of one of the many pitfalls probably knows. Problems such as screen freezing, crashes, uncontrolled ...
user avatar
  • 2,050
12 votes
3 answers
75k views

Validate and import data from an Excel file

I have recently designed a module which will do bulk upload for different contents. Basically the user will upload an Excel file, I will have to read and validate headers of excel then each value of ...
user avatar
  • 655
12 votes
4 answers
1k views

Delete rows in spreadsheet where cells match some patterns

I have vba code that loops through a large number of records and deletes rows based on criteria. The issue at hand is that it takes far too long to run. I have never actually let it finish because it ...
user avatar
12 votes
3 answers
718 views

Perf wrapper for Excel VBA

Spoiler This code is actually BAD for performances! So don't use it! ;) For a while now, I've been using this wrapper to avoid retyping most of it : ...
user avatar
  • 359
12 votes
3 answers
6k views

Parameterised Constructors

Finally, Parameterised Constructors are possible in VBA. Background: One rainy day, I came up with an idea: take a static class and expose one property as default (like it was done in the Reverse for ...
user avatar
12 votes
2 answers
592 views

Averaging a set of percentages between certain important levels

I have a spreadsheet, called "To Do", with set of percentages in column E and importance levels in column A: On another ...
user avatar
  • 417
12 votes
2 answers
513 views

Suspiciously redundant Excel macro code

I need a little help in finding a better solution. In the screen shot below any change to the forecast line I need to find the value in column B. The screen shot is only a sample in my production ...
user avatar
12 votes
2 answers
354 views

Calculation of an inflation on volume/year

I would like to find out if my current solution to the problem described below is "good enough" or if there is an alternative way of achieving it. All I care about is the length (no. of ...
user avatar
12 votes
2 answers
552 views

Forecast maintenance interval for fleet of aircraft

Being new to VBA, and many years removed from college programming courses in Java, I'm seeking opinions about design, implementation, readability and general better practices using VBA to tackle ...
user avatar
12 votes
2 answers
125 views

Follow-up: Randomizing Civilization 5 team choice

This is a follow-up on my previous question about a VBA macro for randomizing a draw from a table. It can be found here: Randomizing Civilization 5 team choice The code has been improved with the ...
user avatar
12 votes
1 answer
206 views

Not so Excellent Knight's Tour

Note: This is part of a set of demo applications I'm writing for colleagues to show we're not limited to VBA when dealing with Excel. Considering our IT challenges (no admin on-site & no local-...
user avatar
  • 12.7k
11 votes
4 answers
728 views

Copying values from one sheet to another

I am trying to copy values from one sheet to another using loop with two conditions and it is very slow. Removing conditions from code doesn't have any effect on the speed of the execution. I already ...
user avatar
  • 213
11 votes
4 answers
650 views

Get Workbook Method(s)

I'm re-writing my Module of standard methods. These 3 are used to retrieve Workbooks as Workbook Objects. The standard I'm aiming for here is "Third-party Library/Add-in". So: Do these functions ...
user avatar
  • 8,800
11 votes
3 answers
665 views

Speeding up execution time of worksheet-formatting code

I've been writing some code that places some data in an empty worksheet and then formats the sheet by adding borders to all of the used cells. The code functions how it should perfect, but it takes a ...
user avatar
11 votes
2 answers
163 views

Extract values within date and zone ranges

In order to automate a manual task I created the following code. As I've never written a program to this size, I'm curious if my use of variables, as well as, solutions are the most optimal way for ...
user avatar
11 votes
2 answers
32k views

Extract Excel data using Interop.Excel from C#

Code Objective I need to create a System.Data.DataSet object from an Excel workbook. Each DataTable within the ...
user avatar
  • 544
11 votes
1 answer
630 views

Copy, Paste And Format

I am currently working with this code to automate some tasks for senior staff members that are not very adept in Excel. Wondering if VBA is simply not a very quick code or if my code is clunky and ...
user avatar
11 votes
2 answers
13k views

Searching a Word Document from Excel

Today I created a script in Excel that migrates data from a specific Word document and copies a portion of it to a cell in Excel (the date to be specific). The file input is Last name, First Name, ...
user avatar
11 votes
1 answer
713 views

Standard Methods in VBA [closed]

Since I learnt about refactoring, I've been busy creating my own Module of Standard Methods. I feel it's about time they got a review of their own. Open to all aspects of advice but particularly ...
user avatar
  • 8,800
11 votes
1 answer
122 views

Recursive code to generate a parametric sweep of input values

I generate a set of data based off every combination of inputs. The source range that's inputs requires headers to identify the parameters. In its present state I'm not content as it's not as ...
user avatar
  • 3,477
11 votes
1 answer
134 views

Function to find the kth match

I've created a UDF some time ago and used it pretty often till now in different ways (but mainly to compare a "history" of data like having different filters at the same time). While there is no need ...
user avatar
11 votes
1 answer
1k views

Drawing Fractals with MS Excel VBA

I've made Excel VBA code that draws and fills a fractal pattern. I know there's a few more ways to optimize the code, just glad it works right now. ...
user avatar
  • 111
10 votes
3 answers
1k views

Macro that does some kind of duplicate check

This macro pulls in two workbooks, one being a template with saved formulas already, and the other containing data with thousands of rows...I need to increase the speed because the process takes more ...
user avatar
  • 125
10 votes
5 answers
963 views

Macro code that removes excess rows

I'm a business student who just started to learn VBA. I am trying to write a macro for a project but only have minimal experience actually stepping into the code. The macro I have written is to ...
user avatar
  • 103
10 votes
4 answers
3k views

Create a list of random numbers with sum = n

I want to create a list of random integers in the range [0, 9], that sums up to 100 in Excel, using VBA. The list should be printed in a single column. The routine I've written is as follows: ...
user avatar
10 votes
3 answers
768 views

MS Excel type of grid in jQuery

I have created an MS Excel type of grid in jQuery. I want to learn best practices and I need your comments for more optimized code. Please review the code and offer your suggestions. Demo jQuery: <...
user avatar
10 votes
2 answers
826 views

Conditionally deleting rows in a worksheet

I have used loops to remove lines that are doing various things, but all are deleting rows where certain criteria is met. Some are deleting less than certain numbers, deleting blanks, removing ...
user avatar
10 votes
3 answers
1k views

Cleaning up and reformatting imported data in an Excel sheet

The code below was refactored for performance improvements for another user on this site. Functionality, high level: Sheet1 - CodeName aIndex: used as the main reference to the structure of the data ...
user avatar
  • 1,154
10 votes
4 answers
5k views

Looping through an Excel document in C#

Before looping through an Excel document using a library I found, and wanted to know how long it would take to loop through the whole thing. There are 40k rows. I looped through only the first 5k ...
user avatar
10 votes
2 answers
211 views

How can I make this userform timer faster?

I have a userform that displays a goal time for workers to shoot for when completing a task. It also has a stopwatch on it that is controlled by a start, stop, and reset button on the userform. If the ...
user avatar
  • 101
10 votes
3 answers
235 views

Userform for getting data from data sheet into a table

I am making a userform that grabs data from a data sheet and puts it into a table: Grabs the data based on what the user wants (Brand -> Items for brand) Allows multiple items to be added Displays ...
user avatar
  • 103
10 votes
2 answers
368 views

Excel-formula-analysis state machine

This is one of my first useful scripts. I run it on a highlighted text selection within Notepad++, but I've provided a sample formula and commented out the Scintilla-specific references. I'm a rank ...
user avatar
  • 223
10 votes
1 answer
1k views

Get table header name in excel

I'm trying to get table header name in excel. I tried it using index, IF and MATCH. It works ...
user avatar
  • 203

1
2 3 4 5
22