SpellNumber Excel VBA
SpellNumber Excel VBA
DecimalSeparator = "."
MyNumber = Trim(Str(MyNumber))
DecimalPlace = InStr(MyNumber, DecimalSeparator)
Count = 1
Do While Units <> ""
Dim Hundreds As String
Hundreds = GetHundreds(Right(Units, 3))
If Hundreds <> "" Then
TempStr = Hundreds & Place(Count) & TempStr
End If
If Len(Units) > 3 Then
Units = Left(Units, Len(Units) - 3)
Else
Units = ""
End If
Count = Count + 1
Loop
Rupees = Application.Trim(TempStr)
If SubUnits <> "" Then
Paise = GetTens(SubUnits)
SpellNumber = Rupees & " Rupees and " & Paise & " Paise"
Else
SpellNumber = Rupees & " Rupees"
End If
End Function
Private Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
GetHundreds = Result
End Function