logo
search
VBA & Macro Problems

Convert Numbers to Malaysian Ringgit and Sen in Excel VBA

Camila MilosovichCamila Milosovich Oct 19, 2026 868 views

Question details

The user wants to convert numerical values into text words formatted as Malaysian currency (Ringgit and Sen) using an Excel VBA macro.

Convert Numbers to Malaysian Ringgit and Sen in Excel VBA
Product
Excel
Device & OS
not provided
Scenario
Generating financial reports, invoices, or receipts where the total numeric amount needs to be spelled out explicitly in Malaysian Ringgit and Sen.
Observed behavior
Standard spreadsheet functions do not spell out numbers in Malaysian currency natively, requiring a custom VBA script to separate the whole numbers and decimals and convert them into Ringgit and Sen text.
Before you start

Ensure your workbook is saved as an Excel Macro-Enabled Workbook (*.xlsm) and that you have enabled macros in your security settings.

Solution 1Recommended

Create a Custom SpellNumber Function in VBA

Use the Visual Basic Editor to insert a custom macro that translates numerical values into written words using Ringgit and Sen.

By modifying a standard SpellNumber VBA script, you can easily adapt it for Malaysian currency. This custom function will handle whole numbers as Ringgit and decimal values as Sen automatically.

1
Open the Visual Basic Editor

Press Alt+F11 on your keyboard to open the Visual Basic Editor (VBE) in Excel.

2
Insert a Standard Module

Click on 'Insert' in the top menu and select 'Module'. This ensures the code is globally accessible across the workbook.

3
Add and Modify the VBA Code

Paste your standard SpellNumber VBA code into the blank module window. Use the Find and Replace tool (Ctrl+H) within the editor to replace all instances of 'Dollar' or 'Dollars' with 'Ringgit', and 'Cent' or 'Cents' with 'Sen'.

4
Save the Workbook

Go to File > Save As, and choose 'Excel Macro-Enabled Workbook (*.xlsm)' from the file type dropdown menu to preserve your new macro.

5
Apply the Custom Function

Return to your worksheet, click on a blank cell, and type `=SpellNumber(A1)` (replace A1 with the cell containing your numeric value) to see the converted text.

Create a Custom SpellNumber Function in VBA
Tip: For a value like 1250.75, the custom function will automatically return 'One Thousand Two Hundred Fifty Ringgit and Seventy-Five Sen'.
Powerful Macro Support

Run VBA Macros Seamlessly in WPS Spreadsheet

WPS Spreadsheet offers excellent compatibility with Excel VBA macros. You can create, edit, and run your custom Ringgit and Sen conversion scripts directly within WPS Office without altering the original code.

  1. 1. Enable Macros: Open your .xlsm file in WPS Spreadsheet and click 'Enable Macros' if prompted by the security warning.
  2. 2. Access the VBA Editor: Navigate to the Developer tab and click 'Visual Basic', or press Alt+F11 to view and edit your conversion code.
  3. 3. Use the Function: Type `=SpellNumber(A1)` in any cell just as you would in Microsoft Excel to convert numeric values to Malaysian currency.
Full support for Excel Macro-Enabled Workbooks (.xlsm)Highly compatible with standard Microsoft Excel VBA scriptsBuilt-in Developer tab for easy macro managementLightweight, fast, and completely free to download
microsoft office alternative - wps office

Frequently Asked Questions

Why does my custom VBA function return a #NAME? error?

This usually occurs if the macro was pasted into a Worksheet module instead of a Standard Module, if macros are disabled in your Trust Center settings, or if the function name was misspelled in the cell.

Can I adapt this VBA code for other currencies besides Ringgit?

Yes. You can open the VBA Editor and replace the text strings 'Ringgit' and 'Sen' with 'Euros' and 'Cents', or 'Pounds' and 'Pence', depending on your specific currency requirements.

Will this macro work if I email the spreadsheet to a colleague?

Yes, as long as you save the file as a Macro-Enabled Workbook (.xlsm) and your colleague enables macros when they open the file on their computer.

Does this function support millions and billions?

Yes, a standard SpellNumber VBA function is designed to support large numbers including thousands, millions, and larger amounts, provided the code includes the logic for those specific tiers.