Convert Number to Hindi word in excel in hindi | How to convert number to word

 Convert Number to Hindi word in excel in hindi | How to convert number to word


Download VBA Code:- Click Here
Download Add ins File:- Click Here

How to word this code please watch this video

Code

Option Explicit Private v100SpellArr() As Variant Private vsectionArr() As Variant Private v_curUnitSpellArr() As Variant Private v_rupeeSign As String Function NumberToHindi(num As Double, _ Optional curSpl As Boolean = False, Optional RsSign As Boolean = False) As String If num = 0 Then NumberToHindi = "" Exit Function End If If v_rupeeSign = "" Then setArrAndVals Dim wholeNum As Long Dim fractionNum As Integer, deciPos As Byte Dim u1 As String, u2 As String, rSgn As String wholeNum = Fix(num) deciPos = InStr(1, CStr(num), ".") If deciPos = 0 Then fractionNum = 0 Else fractionNum = Mid(CStr(num) & "00", deciPos + 1, 2) * 1 End If If curSpl Then u1 = " " & v_curUnitSpellArr(1) & " " u2 = " " & v_curUnitSpellArr(2) End If If RsSign Then rSgn = v_rupeeSign & " " If wholeNum = 0 Then NumberToHindi = rSgn & f_Upto100Spell(fractionNum) & u2 ElseIf fractionNum > 0 Then NumberToHindi = rSgn & f_WholeNumSpell(wholeNum) & " " & u1 & f_Upto100Spell(fractionNum) & u2 Else NumberToHindi = rSgn & f_WholeNumSpell(wholeNum) & u1 End If NumberToHindi = Replace(NumberToHindi, " ", " ") End Function Private Sub setArrAndVals() v100SpellArr = Application.Transpose(Sheet1.Range("a1:a101")) vsectionArr = Application.Transpose(Sheet1.Range("b1:b4")) v_curUnitSpellArr = Application.Transpose(Sheet1.Range("c1:c2")) v_rupeeSign = Sheet1.Range("J1").Value End Sub Private Function f_sectionInNumber(num As Long, secNum As Byte) As Long Dim numStr As String numStr = "000000000" & num Select Case secNum Case 1 f_sectionInNumber = Right(numStr, 3) * 1 '' hundred Case 2 f_sectionInNumber = Left(Right(numStr, 5), 2) * 1 '' thousand Case 3 f_sectionInNumber = Left(Right(numStr, 7), 2) * 1 ''lac Case 4 f_sectionInNumber = Left(num, Len(CStr(num)) - 7) * 1 ''crore End Select End Function Private Function f_Upto100Spell(num As Integer) As String If num = 0 Then f_Upto100Spell = "" Exit Function End If f_Upto100Spell = v100SpellArr(num + 1) End Function Private Function f_HunderedSpell(num As Integer) As String Dim nm As Integer, secSpl As String nm = Left(num, 1) * 1 If nm > 0 Then secSpl = vsectionArr(1) & " " If num > 100 Then f_HunderedSpell = f_Upto100Spell(nm) & " " & _ secSpl & _ f_Upto100Spell(Right(num, 2) * 1) Else f_HunderedSpell = f_Upto100Spell(num) End If End Function Private Function f_ThousandSpell(num As Long) As String Dim nm As Integer, secSpl As String nm = f_sectionInNumber(num, 2) If nm > 0 Then secSpl = vsectionArr(2) & " " f_ThousandSpell = f_Upto100Spell(nm) & " " & _ secSpl & _ f_HunderedSpell(f_sectionInNumber(num, 1)) End Function Private Function f_LacSpell(num As Long) As String Dim nm As Integer, secSpl As String nm = f_sectionInNumber(num, 3) If nm > 0 Then secSpl = vsectionArr(3) & " " f_LacSpell = f_Upto100Spell(nm) & " " & _ secSpl & _ f_ThousandSpell(Right(num, 5) * 1) End Function Private Function f_CroreSpell(num As Long) As String Dim crNum As Integer, crSpl As String crNum = f_sectionInNumber(num, 4) If crNum <= 100 Then crSpl = f_Upto100Spell(crNum) Else crSpl = f_HunderedSpell(crNum) End If f_CroreSpell = crSpl & " " & _ vsectionArr(4) & " " & _ f_LacSpell(Right(num, 7) * 1) End Function Private Function f_WholeNumSpell(num As Long) As String Dim numLen As Byte numLen = Len(CStr(num)) Select Case numLen Case 1, 2, 3 f_WholeNumSpell = f_HunderedSpell(CInt(num)) Case 4, 5 f_WholeNumSpell = f_ThousandSpell(num) Case 6, 7 f_WholeNumSpell = f_LacSpell(num) Case Else f_WholeNumSpell = f_CroreSpell(num) End Select End Function

How to word this code please watch this video

Second Code

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


Download VBA Code:- Click Here Download Add ins File:- Click Here

1 टिप्पणी:

  1. Apne blog ko acchi layout wali theme se attractive banaiye sir mai apke excel k YouTube video daily dekhta hu...pr apka blog utna attractive nhi jabki apke blog par achha traffic ata hoga... mai bhi ek blogger hu sir..

    जवाब देंहटाएं

टिप्पणी: केवल इस ब्लॉग का सदस्य टिप्पणी भेज सकता है.

Send Multiple Emails From Excel | Send Bulk Mail from Excel Sheet with Attachment in One Click

Send Multiple Emails From Excel | Send Bulk Mail from Excel Sheet with Attachment in One Click Download VBA Code Notepad file - Click here D...

Blogger द्वारा संचालित.