Some time we need numbers says in word in a excel cell.
We can use excel function to convert it.
In that function there are several part of calculation :
1. Difinition of words to be used in arrays
2. Looping of three series of numbers.
3. Defining hundreds and teens.
Function SaysInText(Snumber As Double) As String
Dim a, b
'part 1. Definition of words to be used.
a = Array("", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ")
b = Array("", "Ten ", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety ", "Hundred ")
c = Array("", "Thousand ", "Million ", "Billion ")
d = Array("", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen ")
tempor = Snumber
'Part 2. Looping for each three series of numbers.
i = 0
While tempor > 0
'part 3. Check the teens
If (Int(tempor / 10) Mod 10) = 1 And (tempor Mod 10) <> 0 Then
p1 = d(tempor Mod 10)
Else
P2 = b(Int(tempor / 10) Mod 10)
p1 = a(tempor Mod 10)
End If
'Part 4. Check the hundreds
If (Int(tempor / 100) Mod 10) = 0 Then
p3 = ""
Else
p3 = a(Int(tempor / 100) Mod 10) & "Hundred "
End If
SaysInText = p3 & P2 & p1 & c(i) & SaysInText
tempor = Int(tempor / 1000)
i = i + 1
Wend
End Function
You can find the
sample file in the right Box