logo
search
VBA & Macro Problems

Fix Excel Macro Not Recognizing Decimal Values as Currency

Muhammad TalhaMuhammad Talha Oct 9, 2026 869 views

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.

Fix Excel Macro Not Recognizing Decimal Values as Currency
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) window, and find the module containing your refresh macro.

2
Locate the Formatting Code

Find the line of code that writes the value to the cell. It likely looks something like: cell.Value = Format(numericValue, "Currency").

3
Assign the Raw Numeric Value

Change the assignment to write the unformatted number directly to the cell: cell.Value = numericValue.

4
Apply the NumberFormat Property

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 '€').

Write Numeric Values and Apply VBA NumberFormat
Correct Data Types: By separating the value assignment from the formatting, Excel correctly recognizes the underlying data as a Double/Integer, ensuring mathematical operations and visual currency updates work instantly.
VBA Macro Support

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. 1. Open your workbook: Launch WPS Spreadsheet and open your existing macro-enabled workbook.
  2. 2. Access the VBA Editor: Navigate to the Developer tab on the top ribbon and click on 'VBA Editor'.
  3. 3. Update your code: Modify your script to use the cell.NumberFormat method rather than text strings, identical to standard Excel VBA practices.
  4. 4. Run the macro: Execute the script directly within WPS to see decimal values instantly and correctly formatted as currency.
Fully compatible with Microsoft Excel VBA macros and .xlsm filesBuilt-in Developer tools and robust VBA editorLightweight architecture for fast macro execution on large data setsSeamless management of complex formulas and cell formats
microsoft office alternative - wps office

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.