An optimized Excel VBA macro to format cells based on content with a built‑in progress indicator.
- Clears all background colors.
- Applies light green
#EBF1DEto numeric constants. - Applies light blue
#B8CCE4to formulas referencing other sheets only if the result is numeric. - Displays a dynamic progress bar in Excel’s Status Bar during execution.
- Excel with VBA support (Windows or macOS).
- No external dependencies.
- Open your
.xlsmworkbook. - Press
⌘⌥F11to open the VBA editor (orAlt + F11on Windows). - Insert a new module.
- Paste the
FormatCellsByCriteriaWithProgressmacro into the module. - Save the workbook as an Excel Macro‑Enabled Workbook (
.xlsm).
- Open the workbook.
- Press
⌘ + F8(orAlt + F8on Windows). - Select FormatCellsByCriteriaWithProgress and click Run.
- Watch the live progress bar in Excel’s lower-left status bar.
Sub FormatCellsByCriteriaWithProgress()
' [Optimized code with performance settings, progress bar, and selective formatting]
End Sub