English words in indian system in Microsoft

Closed
k.k.Bhandari - Dec 13, 2009 at 03:43 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Jul 13, 2010 at 06:36 AM
Hello,

Kindly mail me the formula to convert numeric value into english words in indian system in Microsoft Excel

&
Function words(fig, Optional point = "Point") As String
Dim digit(14) As Integer
alpha = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
figi = Trim(StrReverse(Str(Int(Abs(fig)))))
For i = 1 To Len(figi)
digit(i) = Mid(figi, i, 1)
Next
For i = 2 To Len(figi) Step 3
If digit(i) = 1 Then
digit(i) = digit(i - 1) + 10: digit(i - 1) = 0
Else: If digit(i) > 1 Then digit(i) = digit(i) + 18
End If
Next
For i = 1 To Len(figi)
If (i Mod 3) = 0 And digit(i) > 0 Then words = "hundred " & words
If (i Mod 3) = 1 And digit(i) + digit(i + 1) + digit(i + 2) > 0 Then _
words = Choose(i / 3, "thousand ", "million ", "billion ") & words
words = Trim(alpha(digit(i)) & " " & words)
Next
If fig <> Int(fig) Then
figc = StrReverse(figi)
If figc = 0 Then figc = ""
figd = Trim(WorksheetFunction.Substitute(Str(Abs(fig)), figc & ".", ""))
words = Trim(words & " " & point)
For i = 1 To Len(figd)
If Val(Mid(figd, i, 1)) > 0 Then
words = words & " " & alpha(Mid(figd, i, 1))
Else: words = words & " Zero"
End If
Next
End If
If fig < 0 Then words = "Negative " & words
End Function

please modify the formula for me
example 1023456..78
Rupees ten Lacs Twenty Three Thousand Four Hundred Fifty Six And Seventy Eight Paisa Only

my alternet ID kkbhandari1@yahoo.co.in
Related:

4 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Dec 14, 2009 at 04:01 AM
open your vb editor and control+R
highlight your file in vb project window and click insert menu - module
there you copy this set of functions
This is slightly modified version of a web page reference r which is given below
This will be valid only for less than one hundred crores.

to explain how to invoke the function:
let us assume some entries are in A1 to A4 like this

123.00
12345.15
1234567.15
987654321.15
in A5 copy this formula

=spellnumber(A1)

copy A5 down up to A8.

A5 to A8 will be

One Hundred Twenty Three Rupees and zero paise
Twelve thousands Three Hundred Forty Five rupees and Fifteen paise
Twelve lacs Thirty Four thousands and Five Hundred Sixty Seven Rupees and Fifteen paise
Ninety Eight crores Seventy Six lacs Fifty Four thousands and Three Hundred Twenty One Rupees and Fifteen paise

The functions are :

'the original function is in "https://www.ozgrid.com/VBA/ValueToWords.htm"
  'this is modified version for Indian system
  'this will be valid only for less than 100 crores

  Function SpellNumber(ByVal MyNumber)
  
  
  
Dim mynumber1, mynumber2, templ, tempc, tempt
          Dim Dollars, Cents, Temp
          Dim DecimalPlace, Count
          ' 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 = "zero"
          If DecimalPlace > 0 Then
              Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
                  "00", 2))
              MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
              
          End If
          
                If Len(MyNumber) <= 3 Then
              Temp = GetHundreds(Right(MyNumber, 3))
              Dollars = Temp & " Rupees " & " and " & Cents & " paise"
              GoTo nextaction
              End If
              If Len(MyNumber) > 3 And Len(MyNumber) <= 5 Then
              Temp = GetHundreds(Right(MyNumber, 3))
              tempt = GetTens(Mid(MyNumber, 1, 2))
              Dollars = tempt & " " & "thousands" & " " & Temp & " " & "rupees" & " " & " and " & Cents & " paise"
              GoTo nextaction
              End If
              If Len(MyNumber) > 5 And Len(MyNumber) <= 7 Then
                            Temp = GetHundreds(Right(MyNumber, 3))
              tempt = GetTens(Mid(MyNumber, 3, 2))
              templ = GetTens(Mid(MyNumber, 1, Len(MyNumber) - 5))
              Dollars = templ & " lacs " & tempt & " thousands " & " and " & Temp & " Rupees " & " and " & Cents & " paise"
              GoTo nextaction
              End If
              If Len(MyNumber) > 7 Then
                  Temp = GetHundreds(Right(MyNumber, 3))
              tempt = GetTens(Mid(MyNumber, 5, 2))
              templ = GetTens(Mid(MyNumber, 3, 2))
                tempc = GetTens(Left(MyNumber, 2))
                Dollars = tempc & " crores " & templ & " lacs " & tempt & " thousands " _
                     & " and " & Temp & " Rupees " & " and " & Cents & " paise"
                GoTo nextaction
                End If
nextaction:
'              MsgBox Temp
'              MsgBox templ
'              MsgBox tempc

          SpellNumber = Dollars

      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

3
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Dec 14, 2009 at 04:09 AM
Mr. Bandari

I have sent a solution for this. It took me some time to modify the Ozgrid functions. So I would be interested if it worked for you. It worked for me. confirm
0
dear I have done everything like above and working properly, but wen i tried to save i got message that "can't save .vb, open a macro-enabled file. after yes, then opening the file the formulae is not working, please help.

Anand
anandkb2000@gmail.com
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Jul 13, 2010 at 06:36 AM
I suppose you are using excel 2007. In excel 2002 and 2003 there will not be a problem.

In excel 2007 do the following (do not just hit control+S)

1. I hope you know how to park the function in the vbeditor
2.click the lefternmost button on the ribbon at the very top. (it is called office button)
3. you will get submenu "save as"
4. when you just touch this "save as" icon with the mouse you will get another set of submenus
5.click excel macro-enable workbook.
6. choose the folder and give a name and click save

now you can use the function for a formula.
0