Relative Content

Tag Archive for arraysexcelvba

Creating an array with a vaiable length (1 dimensional) vba

I have a forecasting procedure that writes out 3 sets of data, with setA dependent on calculations from data in setB and setC – all with the same set of columns for years. Everything is being done via ranges and it runs slow for the relatively few hundred amounts it calculates and writes out. So I have tried to teach myself about arrays by reading other posts and watching videos. And where application meets knwledge, I am failing. For now, I believe I need to use a 1 dimensional array to write to a single row multi-column array. I would perform the calcs within the array as shown below, then write the row out, resetting the output range for each. Then when processing the next account, I would have to reset the range to write out the next row of data. Maybe a 2D array may be easier. I only hesitate on the 2D becasue I am so new to arrays, perhaps baby steps. But for now, I am finding I cannot set up a 1D array with a variable, as debug tells me it must be a constant.

How to search for the last occurrence of a value in a 2-D VBA array and then offset that index to find a different value?

A software of ours produces an Excel file with 28,000 rows and 64 columns. The Excel file has no data formatting; it is a mess of empty cells, titles, headers, tables within tables, etc. What is important for my purposes is finding the first occurrence of a value after the last occurrence of a different value, to import the right numbers into another Excel file. For example: