BInterest

Blog of Ur Interest

Convert / Spell Number in Excel into Words


Working of some project, i was really surprised to know that there is not in build function to convert / spell numbers into the words in Excel 2003 or 2007. Spelling thousands and thousands of Numbers into Words can be a very lengthy work, if you are planning to do it manually. Thanks to one of the friend of mine, who discovered the Spell Numbers Excel VB Function, which can be written and used as a formula in the Excel to convert / spell numbers in to words.

Don’t be afraid if you are not familiar with the VB part of the Excel, nor I was., ! The Process is so simple that you would not even take it 1 full min to write the formula in VP and then use it in the Excel.

Lets Start., Spelling Numbers into Words

How to create the sample function Called Spell Number

  • Start Microsoft Excel.
  • Press ALT+F11 to start the Visual Basic Editor.
  • On the Insert menu, click Module.
  • Type the following code into the module sheet.
Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Rupees, Paisa, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert Paisa and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Paisa = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Rupees = Temp & Place(Count) & Rupees
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Rupees
Case ""
Rupees = "No Rupees"
Case "One"
Rupees = "One Dollar"
Case Else
Rupees = Rupees & " Rupees"
End Select
Select Case Paisa
Case ""
Paisa = " and No Paisa"
Case "One"
Paisa = " and One Cent"
Case Else
Paisa = " and " & Paisa & " Paisa"
End Select
SpellNumber = Rupees & Paisa
End Function

' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = ""           ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else                                 ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1))  ' Retrieve ones place.
End If
GetTens = Result
End Function

' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
  • Now Close Visual Basic.
  • Type Any number in Any Cell , below that Cell right below formula =spellnumber(cell)
  • Press enter
  • You are Done.

Note : The Above Formula is for Indian Rupees and Paise but it can be changed to any currency around the world, Just you have to use the Function Find and Replace two terms. Rupees and Paisa with the respective currency. Hope this works for you.

Stay Tuned to BInterest, for Such tips and tricks for Windows and Office.

You can follow me on Twitter at http://twitter.com/binterest.Do stay tuned to Binterest.com for more, Best Way 2 do it, Subscribe to Binterest's Feed Updates



Related Post :

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.



7 Speak Out ! »

  1. #Howto Convert / Spell Number into Words in Excel (Ready to Use Macro) http://bit.ly/ckeLAp

    Comment by Malvinder Virdi — February 3, 2010 @ 6:07 AM

  2. #Howto Convert / Spell Number into Words in #Excel (Ready to Use #Macro) http://bit.ly/ckeLAp RT @binterest

    Comment by Jill Harper — February 3, 2010 @ 6:14 AM

  3. RT @binterest #Howto Convert / Spell Number into Words in #Excel (Ready to Use #Macro) http://bit.ly/ckeLAp

    Comment by mlomb — February 3, 2010 @ 6:24 AM

  4. Howto Convert / Spell Number into Words in #Excel (Ready to Use #Macro) http://bit.ly/ckeLAp

    Comment by Harsh Agrawal — February 3, 2010 @ 6:28 AM

  5. #Howto Convert / Spell Number into Words in Excel (Ready to Use Macro) http://bit.ly/ckeLAp

    Comment by topsy_top20k_en — February 3, 2010 @ 6:28 AM

  6. Howto Convert / Spell Number into Words in #Excel (Ready to Use #Macro) http://bit.ly/ckeLAp

    Comment by Malvinder Virdi — February 18, 2010 @ 4:15 PM

  7. Social comments and analytics for this post…

    This post was mentioned on Twitter by binterest: #Howto Convert / Spell Number into Words in Excel (Ready to Use Macro) http://bit.ly/ckeLAp...

    Trackback by uberVU - social comments — February 18, 2010 @ 9:48 PM

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Hey, Look @ me I Write this !

    BInterestWelcome to Binterest.com | Am Analyst Cum Blogger, who likes to blog about Free Software, Webware, Giveaway, Firefox & its Add-ons, Tips & Tricks on Microsoft Office 2007 & 2010, Vista & Windows 7, Google, Microsoft. Sharing info which i thing would be worth sharing with readers like U

    Find Me Elsewhere

    Google Profile Twitter Facebook Deviantart Linkedin