Relative Content

Tag Archive for arraysexcelvba

Creating an array with a variable 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.