There are plenty of Google hits for this issue, some from this site, but I can't find any real solution, just the same old stale VBA advice-bites (my apologies if I have been lazy and missed the solution already cached on excelforum.com).
I'm reducing this to the simplest elements that come to mind, although the issue seems to occur in far more general contexts: Excel 2010 versus 2007, incredibly simple macro assigning cell values. Macro is running behind a brand new xlsm workbook, 1 worksheet, created in Excel 2010. All the macro does is assign cell values: .Cells(j, 2).Value = .Cells(j, 1).Value, 500 times.
Time to run in Excel 2007: 0.08 seconds (roughly as expected).
Time to run in Excel 2010: 16+ seconds running the first time on opening the workbook, 5+ seconds for subsequent runs (insane).
The computers I'm using are all modern and powerful enough so hardware is a non-issue. I've been using the workstation running Excel 2010 (and Win8.1) for more than a year with no Excel problems except this one ... I'm a super-ultra-extreme VBA power user running awesomely complex spreadsheets with horrendously extreme calculation loads, and the Excel 2010 box handles everything great (fastest box I have) except when it comes to issues like this ("messing around with cells", to put it generically).
I think I've tried just about every Application-level setting and Workbook-level setting that might apply, but hopefully I've missed something very simple you folks can point out.
Sample code:
Sub test_Excel10()
Dim j As Long, xTime As Double
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
'Application.EnableEvents = False
'Application.DisplayAlerts = False
'Application.AutomationSecurity = msoAutomationSecurityForceDisable
xTime = Timer
With Worksheets(1)
For j = 1 To 500
.Cells(j, 2).Value = .Cells(j, 1).Value
Next j
End With
xTime = Timer - xTime
MsgBox "Time = " & Format$(xTime, "0.00")
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
'Application.EnableEvents = True
'Application.DisplayAlerts = True
'Application.AutomationSecurity = msoAutomationSecurityLow
End Sub
Bookmarks