If your Excel VBA code runs without errors but the cells never change, the cause is almost always one of a handful of issues: calculation is set to manual, events are disabled, the code is writing to the wrong sheet or workbook, or the code never actually runs. This guide walks you through diagnosing and fixing each of these, starting with the quickest checks first.
What You'll Need
- Excel for Windows or Mac with the Developer tab available (File > Options > Customize Ribbon, then tick Developer on Windows; on Mac, Excel > Preferences > Ribbon & Toolbar). Menu labels can differ slightly between versions and platforms.
- Your workbook saved as a macro-enabled file (.xlsm), not a plain .xlsx, if it contains code.
- Macros enabled for the workbook (click Enable Content in the security bar when prompted).
- Basic familiarity with the VBA editor (press Alt + F11 on Windows, or Option + F11 on Mac).
Step-by-Step
- Check that the code actually runs. Press Alt + F11 to open the VBA editor, click inside your macro, and press F5 to run it. If nothing happens visually, add a simple line near the top of the macro, such as
MsgBox "Running", and run again. If the message box never appears, the macro is not executing, so scroll down to Troubleshooting for macro security and event issues. - Verify calculation mode. VBA writes values instantly, but formulas elsewhere will not recalculate if calculation is set to manual. In the VBA editor's Immediate window (Ctrl + G to show it), type
?Application.Calculationand press Enter. If it returns-4135(xlCalculationManual), addApplication.Calculation = xlCalculationAutomaticat the start of your macro, or callApplication.Calculateafter writing values. - Confirm you are writing to the right sheet. An unqualified reference like
Range("A1").Value = 5writes to whichever sheet happens to be active. If your workbook has multiple sheets, qualify the reference:Worksheets("Sheet1").Range("A1").Value = 5. This single change fixes a large share of "cells not updating" reports, because the value was written somewhere you were not looking. - Check the workbook, not just the sheet. If you have more than one workbook open, an unqualified
Rangecan write to the wrong file entirely. UseThisWorkbook.Worksheets("Sheet1").Range("A1").Value = 5to guarantee the code touches the workbook containing the macro. - Look at your Workbook_Open or Worksheet_Change logic. If cells should update when the file opens or when you edit something, open the ThisWorkbook module or the sheet's code module and confirm the event procedure names are spelled exactly right (
Workbook_Open,Worksheet_Change). A typo means Excel silently ignores the procedure. - Check whether events got switched off. If any code ever ran
Application.EnableEvents = Falseand crashed before turning events back on, change events will not fire for the rest of the session. In the Immediate window typeApplication.EnableEvents = Trueand press Enter, then test again. To prevent this, add an error handler that always restores EnableEvents to True. - Check screen updating separately. If the values are actually changing but the screen looks frozen,
Application.ScreenUpdatingwas probably left False. TypeApplication.ScreenUpdating = Truein the Immediate window. Verify by clicking a cell and reading the formula bar, which updates independently of repaint. - Inspect the value you are writing. If you write
""or a variable that is empty, the cell will look unchanged. Step through the code with F8 and hover over variables to confirm they hold what you expect. Watch for text versus numbers:Range("A1").Value = "5"stores text that some formulas will ignore. - Check the cell format after writing. A date or number written correctly can still display oddly if the cell format is Text set before the write. Write the value, then apply
Range("A1").NumberFormat = "General"or re-enter the value after changing the format. - Force a repaint and recalculation when needed. For long loops, adding
DoEventsinside the loop lets Excel refresh the display, andApplication.Calculateat the end brings dependent formulas up to date. Close the macro with ScreenUpdating restored to True so the workbook looks normal afterwards. - Save and reopen as a test. Save the file as .xlsm, close Excel completely, reopen the file, enable macros, and run the macro again. A fresh session clears stuck application states such as manual calculation or disabled events carried over from other workbooks.
Common Mistakes
- Leaving
Application.ScreenUpdating = FalseorEnableEvents = Falseunset when an error interrupts the macro mid-run. - Using unqualified Range references in workbooks with multiple sheets, so values land on the wrong sheet.
- Saving the workbook as .xlsx after adding code, which strips the macros entirely.
- Expecting a Worksheet_Change event to fire after a VBA write. Changing a cell from code does not re-trigger that sheet's own Change event unless you call the logic yourself.
- Forgetting that calculation can be set to manual by another open workbook, because calculation mode is application-wide, not per-file.
Tips
- Use the Immediate window as your diagnostic panel: check
Application.Calculation,Application.EnableEvents,Application.ScreenUpdating, andActiveSheet.Namein seconds. - Build a standard error handler that restores all three application settings, so a crash never leaves Excel in a broken state.
- Prefer
ThisWorkbookand fully qualified sheet names overActiveSheetfor any write that matters. - Step through new code with F8 before trusting it. Most silent failures become obvious one line at a time.
Troubleshooting
If the macro will not run at all, check these in order. First, confirm macros are enabled: on Windows go to File > Options > Trust Center > Trust Center Settings > Macro Settings and make sure macros are not disabled; on Mac look in Excel > Preferences > Security. Second, confirm the file is .xlsm, not .xlsx, since .xlsx cannot store code. Third, if the macro is missing from the Macro dialog (Alt + F8), it may be declared Private or live in a class module, neither of which shows there. Fourth, restart Excel completely, because application-wide states from other open workbooks can persist and interfere. As a last resort, export your modules from the VBA editor (right-click the module, choose Export File) and import them into a fresh workbook, in case the file itself is corrupted.
Frequently Asked Questions
Why does my macro work when I run it manually but not on its own?
Automatic triggers depend on events. If Application.EnableEvents is False, or the event procedure name is misspelled in the wrong module, the code only runs when you start it yourself. Reset EnableEvents to True and check the procedure names.
Cells change but formulas do not recalculate. Why?
Calculation is set to manual. Set Application.Calculation = xlCalculationAutomatic, or call Application.Calculate at the end of your macro. Note this setting is shared by every open workbook.
The screen freezes while the macro runs. Is it broken?
Usually not. Application.ScreenUpdating = False deliberately hides changes for speed. Wait for the macro to finish, and if the screen stays frozen afterwards, set ScreenUpdating back to True in the Immediate window.
My variable writes blank into the cell. What is wrong?
The variable is empty at the moment of the write. Step through with F8 and hover over the variable. Common causes include reading from the wrong cell, an unqualified Range, or a lookup that never matched.
Does Worksheet_Change fire when VBA changes a cell?
No. VBA writes do not re-trigger the Change event for that sheet. If you need the same logic to run, move it into a normal sub and call it from both the event procedure and your other code.
Why does the value appear but the formula bar shows something else?
The cell format is Text, so Excel displays exactly what was stored. Set NumberFormat to General, then write the value again.