Showing posts with label calculation. Show all posts
Showing posts with label calculation. Show all posts

April 6, 2010

Disable Excel events

How to accelerate the refresh of data connections in a large Excel workbook which has macros triggered by events: disable the events before refreshing the connections, then re-enable the events.

Sub refresh_data()
'disables events, updates data connections, then enables events.

Application.EnableEvents = False
'code to execute with events disabled:
ActiveWorkbook.RefreshAll
Application.EnableEvents = True

End Sub

March 9, 2010

Faster iterative calculation of a worksheet with circular references


Sub fastcalc()

  'disable screen updating:
  Application.ScreenUpdating = False

  For i = 1 To 100
    Selection.Calculate 'recalculate only the selected range
  Next i

  'enable screen updating:
  Application.ScreenUpdating = True

End Sub