A simple VBA macro that highlights and converts numbers stored as text in Excel to actual numeric values, preserving the number format.
- highlight cells with numbers stored as text
- confirm and create a backup
- convert values using CDbl() while preserving decimal formatting
- works across all sheets in a workbook
- Download
TextToNumber.bas
file from this repo. - Open target
.xlsx
file in Excel. - Activate Developer mode following
File > Options > Costumise Ribbon
, then check the box Developer in the right-hand list. ClickOK
. - Find
Developer
tab and clickVisual Basic
to open the VBA editor. - In the VBA editor, go to
File > Import File...
, and select theTextToNumber.bas
file (which should be located in the same directory). - Go to
Developer > Macros
, selectTextNumberConverterWizard
, and clickRun
. (Alternatively, press Alt + F8, choose the macro, and click Run.)
You will be prompted to:
- Highlight problematic cells
- Optionally create a backup
- Convert text-formatted numbers to proper numeric format