• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Spell Currency Indian Scenario

somnath6309

New Member
The code of spell currency received from Mr. John Walkenbach's book "excel 2013 power programming with vba"

the file with code has been attached herewith.

But the fact is that the code has been developed for foreign country scenario and in our india Rs. 111533120 is spelled as eleven crore fifteen lac thirty three thousand one hundred twenty i.e the parsing method is :

11/15/33/120
I want to use the code for our indian scenario. Is it possible to make necessary changes in the code to serve the purpose. Looking for a positive reply. I have uploaded the file herewith.
 

Attachments

  • spelldollars function.xlsm
    18.9 KB · Views: 3
Code:
Function ewords(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
ewords = "Rupees "
ElseIf Val(Left(FIGURE, 9)) = 1 Then
ewords = "Rupee "
End If

For i = 1 To 3
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
ewords = ewords & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
ewords = ewords & tens(Val(Left(FIGURE, 1)))
ewords = ewords & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If

If i = 1 And Val(Left(FIGURE, 2)) > 0 Then
ewords = ewords & "Crore "
ElseIf i = 2 And Val(Left(FIGURE, 2)) > 0 Then
ewords = ewords & "Lakh "
ElseIf i = 3 And Val(Left(FIGURE, 2)) > 0 Then
ewords = ewords & "Thousand "
End If
FIGURE = Mid(FIGURE, 3)
Next i

If Val(Left(FIGURE, 1)) > 0 Then
ewords = ewords & 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
ewords = ewords & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
ewords = ewords & tens(Val(Left(FIGURE, 1)))
ewords = ewords & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
FIGURE = Mid(FIGURE, 4)

If Val(FIGURE) > 0 Then
ewords = ewords & "Paise "
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
ewords = ewords & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
ewords = ewords & tens(Val(Left(FIGURE, 1)))
ewords = ewords & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
End If
FIGURE = amt
FIGURE = Format(FIGURE, "FIXED")
If Val(FIGURE) > 0 Then
ewords = ewords & "Only"
End If
End Function


=ewords()


if u need same in GUJARATI then tell me :)
 
Last edited:
Back
Top