Wauvel

Excel like a finance pro.

The functions, VBA, and shortcuts a finance operator actually uses — curated, with CFO examples. Prefer them pre-built? Grab a ready-made model.

← All VBA snippets

Make any macro 10-100x faster

Wrap slow code so Excel stops repainting and recalculating on every change — the single biggest speed win.

1What it does

Turns off screen redraw, automatic calculation, and events for the length of the macro, then restores them — even if the macro errors, thanks to the On Error GoTo Cleanup pattern. On a big loop this routinely takes a run from a minute of flickering to under a second, because Excel isn't re-painting and re-calculating after every cell you touch.

2The code

Sub FastMacro()
    ' Wrap any slow macro in these. Turning off screen redraw, auto-calc, and
    ' events stops Excel re-painting and re-calculating on every change —
    ' routinely 10-100x faster on big loops.
    Dim calcMode As XlCalculation
    calcMode = Application.Calculation

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False

    On Error GoTo Cleanup   ' ALWAYS restore, even if the work below errors

    ' ---- your slow work goes here ----
    Dim i As Long
    For i = 2 To 50000
        Cells(i, "C").Value = Cells(i, "A").Value * Cells(i, "B").Value
    Next i
    ' ----------------------------------

Cleanup:
    Application.EnableEvents = True
    Application.Calculation = calcMode      ' restore whatever it was before
    Application.ScreenUpdating = True
    If Err.Number <> 0 Then MsgBox "Stopped: " & Err.Description
End Sub

Paste into the Visual Basic Editor (Alt + F11 → Insert → Module), then run and save as macro-enabled (.xlsm).

New to macros? Set up in 5 minutes
  1. 1

    Don't see the Developer tab in the ribbon?

    You don't strictly need it — Alt + F11 opens the editor directly — but it makes running macros easier.
    • Windows: File → Options → Customize Ribbon → tick Developer in the right-hand list → OK.
    • Mac:Excel → Preferences → Ribbon & Toolbar → tick Developer → Save.
  2. 2

    Paste in the code

    Press Alt + F11 to open the Visual Basic editor, then Insert → Moduleand paste the snippet's code into the blank window. Close it with Alt + Q.
  3. 3

    Run it

    Press Alt + F8, pick the macro's name, and click Run — that's it. (Pasted a custom function instead? Just type it into a cell like any built-in: =GrossMargin(B2, B3).)
  4. 4

    Keep the macro — save as .xlsm

    File → Save As → Excel Macro-Enabled Workbook (.xlsm). A plain .xlsx silently drops the code when you save.
  5. 5

    Macros blocked?

    Click Enable Content on the yellow bar. If you downloaded the file, you may first need to right-click it → Properties → tick Unblock → OK, then reopen.

Heads up: macros can't be undone with Ctrl + Z — save a copy before running one that changes your workbook.

3When you use it

  • Speed up any macro that writes to lots of cells in a loop.
  • Stop the screen from flickering while a macro runs.
  • Prevent your own change-events from firing during a bulk update.

4See it in action

A simulation — press Run to perform what the macro does to a sample workbook.

Without the wrapper~42s · screen flickers
With the wrapper

5Pitfalls

The macro errors and leaves calc on Manual or the screen frozen.

Fix: Always restore in a Cleanup label reached by On Error GoTo — never only at the end.

Hard-coding Calculation = xlCalculationAutomatic on the way out, when it started Manual.

Fix: Save the old mode first (calcMode = Application.Calculation) and set it back to that.

6No-code alternatives

  • Read/write arrays Touching the sheet once through a variant array is faster still for big data.
  • Calculation only If flicker isn't the problem, just toggling calc off can be enough.

Rather not write macros? Wauvel's free tools generate branded, formula-driven Excel for you — no VBA required.

Learn the moves here — or let Wauvel run them on your numbers.

Get my free report →