1. Start Microsoft Excel.
2. Press ALT+F11 to start the Visual Basic Editor.
3. On the Insert menu, click Module.
4. Type the following code into the module sheet.
Option Explicit
‘Main Function
Function SpellNumber(ByVal MyNumber)
Dim Baht, Satang, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
’ String representation of amount.
MyNumber = Trim(Str(MyNumber))
’ Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, “.”)
’ Convert Satang and set MyNumber to Baht amount.
If DecimalPlace > 0 Then
Satang = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
“00”, 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Baht = Temp & Place(Count) & Baht
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Baht
Case ""
Baht = “No Baht”
Case “One”
Baht = “One Baht”
Case Else
Baht = Baht & " Baht"
End Select
Select Case Satang
Case ""
Satang = " Only"
Case “One”
Satang = " and One Satang"
Case Else
Satang = " and " & Satang & " Satang"
End Select
SpellNumber = Baht & Satang
End Function
...