Excel calculation time increasing disproportionately with more columns

101 views Asked by At

I'm looking for a way to avoid needing to transpose a bunch of workbooks.

I have a large amount of data on a worksheet that has recently become about 3x larger (same # of rows, 3x more columns). However, instead of increasing calculation time for things like ClearContents by 3x, it's increased by 18x.

Specifically, I have data in the first 360 rows and first 2000 columns. However, I now need to increase the number of columns to 6000. When I use a macro to ClearContents (calculation manual, screenupdating false) it takes 13 seconds to clear 360 rows x 2000 columns, but upwards of 230 seconds to clear 360 rows x 6000 columns.

Also, I don't have data in most of those 6000 columns. It's just that I've had to offset some of the rows (so, a row that had data in columns A:BXZ now has data in columns DKJ:GJH, for example, with columns A:DJI left blank). So it's the same number of non-blank cells as when I had 2000 columns.

When I tried transposing everything (6000 rows, 360 columns), I found it takes 14 seconds to clear -- much faster!

Is there a reason that it takes so much longer when the sheet increases columns compared to rows, and if so, is there a setting I can change? We have a bunch of workbooks that extend right instead of down and I'm really not looking forward to converting all of them. They have a lot of associated VBA macros, so it's not as simple as copy-->paste transpose for me to do that.

Edit: The code I used to test the ClearContents speed is this:

Sub testDelete2()
Application.Calculation = xlManual
Application.ScreenUpdating = False

Dim time1
    time1 = Timer

'Worksheets("Sheet1").Range("C5:BXY360").ClearContents      '2000 columns
'Worksheets("Sheet1").Range("C5:IPB360").ClearContents      '6000 columns
'Worksheets("Sheet1").Range("E3:MV2041").ClearContents      '2000 rows
Worksheets("Sheet1").Range("E3:MV5723").ClearContents       '6000 rows

Debug.Print Timer - time1

Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub

The cells that have data in them have a formula to look up data from a 3000Rx2000C table on another sheet using INDEX/MATCH. Cells that are before the offset or after the datarange for that row are left blank, they don't have any formulas.

0

There are 0 answers