Convert Number to words in left to right direction 0-9

Bhanu Singh 21 Reputation points
2022-08-09T07:18:46.29+00:00

If we enter a number it will convert into individual strings and display in same order.

Ex: If I enter 564 then the output should be FIVE SIX FOUR.

I need VBA Code to work in excel.

Microsoft 365 and Office | Development | Other
Developer technologies | VB
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2022-08-09T09:38:23.88+00:00

    Check an example:

    Dim entered_number As Long  
    entered_number = 564  
      
    Dim s As String  
    s = CStr(entered_number)  
      
    Dim a(9) As String  
    a(0) = "ZERO"  
    a(1) = "ONE"  
    a(2) = "TWO"  
    a(3) = "THREE"  
    a(4) = "FOUR"  
    a(5) = "FIVE"  
    a(6) = "SIX"  
    a(7) = "SEVEN"  
    a(8) = "EIGHT"  
    a(9) = "NINE"  
      
    Dim result As String  
    Dim i As Integer  
      
    For i = 1 To Len(s)  
      
        result = result & a(CInt(Mid(s, i, 1))) & " "  
          
    Next  
      
    MsgBox result  
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.