Looping through an Array to load cells has slow performance

Vancity

New Member
Joined
Sep 24, 2008
Messages
17
I have a 7x2 array with integer values in the first dimension and column # stored in the second.
Below I've looped through the array to load 7 cells, but performance takes a HUGE hit.
Code:
For i = 1 To 7
                Cells(ActiveCell.Row, sngArrayCT(i, 2)) = sngArrayCT(i, 1)
 Next i
I've read that this should be avoided, whats the proper way?
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,562
Office Version
365
Platform
Windows
The proper way to do what exactly?:eek:

Where do the values in the array come from and where are they going?:)
 

Vancity

New Member
Joined
Sep 24, 2008
Messages
17
The value in the array is calculated, and the column number loaded in another process. These values need to be loaded into the given column number for the active row.

The reason the column numbers are in the array is that they are found by using a Find function on the header of the data (which comes from an Oracle DB). I didn't want to hard code col #'s in, so I store them with the new value in the array.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,626
Messages
5,469,785
Members
406,670
Latest member
Jimborusk13

This Week's Hot Topics

Top