Skip to main content

Excel Function to Convert Rupees in Figure to Rupees in Word

Excel Function to Convert Rupees in Figure to Rupees in Word

Following function convert ( Rupees in figure ) numeric value in a Microsoft Excel worksheet cell into its equivalent in (Rupees in Word ) English words.
e.g.  =SpellNumber(2450) will display as Rupees Two Thousand Four Hundred Fifty Only

After copying following code, Enable macro and use above function.

How to create the sample function Called SpellNumber

  1. Start Microsoft Excel.
  2. Press ALT+F11 to start the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. Type the following code into the module sheet.

Function SpellNumber(amt As Variant) As Variant
Dim FIGURE As Variant
Dim LENFIG As Integer
Dim i As Integer
Dim WORDs(19) As String
Dim tens(9) As String
WORDs(1) = "One"
WORDs(2) = "Two"
WORDs(3) = "Three"
WORDs(4) = "Four"
WORDs(5) = "Five"
WORDs(6) = "Six"
WORDs(7) = "Seven"
WORDs(8) = "Eight"
WORDs(9) = "Nine"
WORDs(10) = "Ten"
WORDs(11) = "Eleven"
WORDs(12) = "Twelve"
WORDs(13) = "Thirteen"
WORDs(14) = "Fourteen"
WORDs(15) = "Fifteen"
WORDs(16) = "Sixteen"
WORDs(17) = "Seventeen"
WORDs(18) = "Eighteen"
WORDs(19) = "Nineteen"
tens(2) = "Twenty"
tens(3) = "Thirty"
tens(4) = "Fourty"
tens(5) = "Fifty"
tens(6) = "Sixty"
tens(7) = "Seventy"
tens(8) = "Eighty"
tens(9) = "Ninety"
FIGURE = amt
FIGURE = Format(FIGURE, "FIXED")
FIGLEN = Len(FIGURE)
If FIGLEN < 12 Then
FIGURE = Space(12 - FIGLEN) & FIGURE
End If
If Val(Left(FIGURE, 9)) > 1 Then
SpellNumber = "Rupees "
ElseIf Val(Left(FIGURE, 9)) = 1 Then
SpellNumber = "Rupee "
End If
For i = 1 To 3
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
If i = 1 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & " Crore "
ElseIf i = 2 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & " Lakh "
ElseIf i = 3 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & " Thousand "
End If
FIGURE = Mid(FIGURE, 3)
Next i
If Val(Left(FIGURE, 1)) > 0 Then
SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 1))) + " Hundred "
End If
FIGURE = Mid(FIGURE, 2)
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
FIGURE = Mid(FIGURE, 4)
If Val(FIGURE) > 0 Then
SpellNumber = SpellNumber & " Paise "
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
End If
FIGURE = amt
FIGURE = Format(FIGURE, "FIXED")
If Val(FIGURE) > 0 Then
SpellNumber = SpellNumber & " Only "
End If
End Function

Comments

  1. Option Explicit

    'Main Function

    Function SpellNumber(ByVal MyNumber)

    Dim Dollars, Cents, 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 cents and set MyNumber to dollar amount.

    If DecimalPlace > 0 Then

    Cents = 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 Dollars = Temp & Place(Count) & Dollars

    If Len(MyNumber) > 3 Then

    MyNumber = Left(MyNumber, Len(MyNumber) - 3)

    Else

    MyNumber = ""

    End If

    Count = Count + 1

    Loop

    Select Case Dollars

    Case ""

    Dollars = "No Dollars"

    Case "One"

    Dollars = "One Dollar"

    Case Else

    Dollars = Dollars & " Dollars"

    End Select

    Select Case Cents

    Case ""

    Cents = " and No Cents"

    Case "One"

    Cents = " and One Cent"

    Case Else

    Cents = " and " & Cents & " Cents"

    End Select

    SpellNumber = Dollars & Cents

    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

    ReplyDelete

Post a Comment

Popular posts from this blog

માતાજીના છંદ - અમીચંદ

  માતાજીના છંદ - અમીચંદ    અંબા મા તારું દર્શન દુર્લભ, દર્શનથી દુઃખ ભાંગે છે, અરજ કરી માને શીશ નમાવું, ધનભાગ્ય મારું આજે છે...   લક્ષ ચોર્યાશી ફેરા ફરીને, મનસા અવતાર ધરાવ્યો છે, ગુલામ તમારો આવ્યો મુસાફર, માયામાં લપટાયો છે...   કામ, ક્રોધ, મોહ, મત્સર, માયા દુર્મતિ પર ધાયો છે, લોભ લહેર એક નદીયા વહે છે, ઉસમેં જીવ દુભાયો છે...   તુમ બીના પાર ઉતારે કોણ મા, ભક્તને કે શિર ગાજે છે, અરજ કરીને માને શીશ નમાવું, ધનભાગ્ય મારું આજે છે...   કોઈ વખત જીવ જાયે ધરમ પર, માયા પાછી લપટાવે છે, આકીન અમારું રહેતું નથી, મારું પાપ મને અથડાવે છે...   હવે ઉપાય શું કરું માતાજી, હમકું કોઈ બતાવે છે, ચાકર બેઠો ચિત્તમાં તમારો, દિલમાં બહુ ગભરાવે છે...   મારી હકીકત તું સહુ જાણે, ઘટઘટમાં તું બિરાજે છે, અરજ કરી માને શીશ નમાવું, ધનભાગ્ય મારું આજે છે...   માન નિરંજન તું દુઃખભંજન, નિરધનને ધન આપે છે, વાંઝિયા હોય તેનું મેણું ટાળી, તેને તું ફરજંદ આપે છે...   ભક્ત કરે મા ભક્તિ તમારી, તેને તું દર્શન આપે છે, જન્મોજનમનાં પાપ નિવારણ, એક પલકમાં કાપે છે...   બહુચર-

SBI ATM Card Application Form - State Bank of India

How to Convert Numbers to Words in Excel

How to Convert Numbers to Words in Excel format Cell _(#,##0.00_);[Red](#,##0.00) = CHOOSE(LEFT(TEXT(B3,"000000000000.00"))+1,,"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ")&IF(--LEFT(TEXT(B3,"000000000000.00"))=0, ,IF(AND(--MID(TEXT(B3,"000000000000.00"),2,1)=0,--MID(TEXT(B3,"000000000000.00"),3,1)=0),"Hundred ","Hundred and "))&CHOOSE(MID(TEXT(B3,"000000000000.00"),2,1)+1,,,"Twenty ","Thirty ","Forty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety ")&IF(--MID(TEXT(B3,"000000000000.00"),2,1)<>1,CHOOSE(MID(TEXT(B3,"000000000000.00"),3,1)+1,,"One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ",&quo