Fix Excel Macro Not Recognizing Decimal Values as Currency
Question details
The user needs to correctly format decimal values as currency using a VBA macro without having to manually double-click or edit the cell afterward.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running a VBA macro to refresh a data range and automatically apply a currency format to numerical values.
- Observed behavior
- The macro formats whole numbers properly, but decimal values remain unrecognized as plain text or unformatted numbers. The decimals only display as currency after the user manually interacts with the cell.
Check your VBA macro code to see if you are using the Format function to write data. Writing pre-formatted strings instead of raw numbers is the most common cause of this recognition issue.
Write Numeric Values and Apply VBA NumberFormat
Instead of pushing formatted text strings into the cell, assign the raw underlying number and format the cell directly using the VBA NumberFormat property.
When you use VBA's Format function (e.g., Format(value, "Currency")), Excel receives a text string rather than a numerical value. While Excel sometimes auto-converts whole number strings, it often fails on decimals, requiring manual cell interaction to trigger a recalculation.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) window, and find the module containing your refresh macro.
Find the line of code that writes the value to the cell. It likely looks something like: cell.Value = Format(numericValue, "Currency").
Change the assignment to write the unformatted number directly to the cell: cell.Value = numericValue.
Add a new line immediately below it to handle the visual formatting: cell.NumberFormat = "R#,##0.00" (replace 'R' with your desired currency symbol like '$' or '€').

Use Find and Replace to Force Value Recognition
If you cannot edit the macro code immediately, you can use Excel's Find and Replace feature as a quick workaround to force the spreadsheet to recognize the text as standard numbers.
How to Run Currency Formatting Macros in WPS Spreadsheet
WPS Office offers full VBA compatibility. You can flawlessly write, edit, and run your macros in WPS Spreadsheet to ensure that numeric formatting is handled correctly without manual cell edits.
- 1. Open your workbook: Launch WPS Spreadsheet and open your existing macro-enabled workbook.
- 2. Access the VBA Editor: Navigate to the Developer tab on the top ribbon and click on 'VBA Editor'.
- 3. Update your code: Modify your script to use the cell.NumberFormat method rather than text strings, identical to standard Excel VBA practices.
- 4. Run the macro: Execute the script directly within WPS to see decimal values instantly and correctly formatted as currency.

Frequently Asked Questions
Why do decimal values only refresh after I click inside the cell?
When a macro writes a formatted string into a cell using the Format function, Excel treats the data as text. Double-clicking the cell and pressing Enter triggers Excel's automatic evaluation, which forces it to re-read the string and convert it into a numeric value.
Does disabling screen updating cause this formatting glitch?
No. Using 'Application.ScreenUpdating = False' is a best practice to prevent screen flicker and speed up macros. However, it does not affect how Excel parses cell data types. The issue strictly relates to passing strings instead of numbers.
Why do whole numbers format successfully while decimals fail?
Excel attempts to auto-correct and guess data types. It can often successfully convert a simple string that looks like a whole number back into a numeric value. However, complex strings involving decimal separators and currency symbols frequently confuse this auto-conversion, causing the data to remain as text.




