Skip to main content

Number convert to words

Number convert to words 


Virtual Learning Earning Channel

Steps to Add the Macro

  1. Open Excel and press ALT + F11 to open the VBA Editor.
  2. Click Insert > Module.
  3. Copy and paste the code below into the module.
  4. Close the VBA Editor and return to Excel.
  5. Use the function in a cell like =NumberToWords(A1).

VBA Code for Digit-by-Digit Conversion


Function NumberToWords(ByVal MyNumber As String) As String

    Dim i As Integer

    Dim Result As String

    Dim Digit As String

    

    ' Loop through each digit in the number

    For i = 1 To Len(MyNumber)

        Digit = Mid(MyNumber, i, 1)

        Select Case Digit

            Case "0": Result = Result & " Zero"

            Case "1": Result = Result & " One"

            Case "2": Result = Result & " Two"

            Case "3": Result = Result & " Three"

            Case "4": Result = Result & " Four"

            Case "5": Result = Result & " Five"

            Case "6": Result = Result & " Six"

            Case "7": Result = Result & " Seven"

            Case "8": Result = Result & " Eight"

            Case "9": Result = Result & " Nine"

        End Select

    Next i

    

    ' Trim leading space and return the result

    NumberToWords = Trim(Result)

End Function


How to Use:

  • In Excel, enter a number in a cell (e.g., 123 in A1).
  • In another cell, type:
    =NumberToWords(A1)
  • It will return:
    "One Two Three"

Comments

Popular posts from this blog

Spell Number Function

  How to Convert Number into Words in MS Excel | Spell Number in Excel | MS Excel Tips & Tricks @1 In Microsoft Excel, you can't directly write a function like a traditional programming language. However, you can use  VBA (Visual Basic for Applications)  to create custom functions, like a "spell" function, which converts numbers into words. Here's an example of how to write a  VBA spell function  that converts numbers to words in Excel: Step-by-step guide to create the function: Open Excel. Press  Alt + F11  to open the  VBA editor . In the VBA editor, click  Insert  >  Module . Paste the following code into the module:   Function SpellNumber(ByVal MyNumber)     Dim Units As String     Dim Cents As String     Dim DecimalPlace As Integer     Dim Count As Integer     Dim Place(9) As String     Dim Hundreds As String          Pl...

Automatically update work sheets based on the Account field

        To automatically update sheets based on the Account field, you can use VBA in Excel. This script will check the Account field in your main sheet and transfer rows to the corresponding sheet for each account. Here's how to set it up: . Using VBA (Fully Automated Solution) If you want the data to be copied automatically whenever you enter it in the main sheet, you can use a VBA script. Steps to Implement VBA: Press Alt + F11 to open the VBA editor. Go to Insert > Module and paste the following code: VBA Script for Automatic Sheet Updates Sub UpdateAccountSheets()     Dim wsMain As Worksheet     Dim wsAccount As Worksheet     Dim lastRow As Long, i As Long     Dim accountName As String     Dim accountSheet As Worksheet     Dim accountLastRow As Long     Dim lastProcessedRow As Long          ' Set the main worksheet     Set wsMain = ThisWorkbook.Sheets("M...