Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function DollarsToText(amount)
' DollarsToText created 26/4/00
' Converts Amounts to Text (ex Ins Ms Excel Oct 97)
' with some additional mods to Australianise it
'
If amount >= 1000000 Or amount < 0 Then
DollarsToText = "***VOID***"
Exit Function
End If
hth = Int(amount / 100000)
tth = Int((Int(amount) Mod 100000) / 10000)
th = Int((Int(amount) Mod 10000) / 1000)
h = Int((Int(amount) Mod 1000) / 100)
t = Int((Int(amount) Mod 100) / 10)
o = Int((Int(amount) * 100 Mod 1000) / 100)
C = Application.Round(amount - Int(amount), 2) * 100
array1 = Array("One ", "Two ", "Three ", "Four ", "Five ", "Six ", _
"Seven ", "Eight ", "Nine ")
array2 = Array("Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", _
"Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen ")
array3 = Array("", "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", _
"Seventy ", "Eighty ", "Ninety ")
If hth = 0 Then
part1 = ""
Else
part1 = array1(hth) & "Hundred "
End If
If tth = 0 And th < 1 Then
part1and = ""
Else: part1and = "and "
End If
If amount < 100000 Then
part1and = ""
End If
If tth = 0 Then
part2 = ""
ElseIf tth = 1 Then
part2 = array2(tth + th)
Else
part2 = array3(tth)
End If
If th = 0 Or tth = 1 Then
part3 = ""
Else
part3 = array1(th)
End If
If hth = 0 And tth = 0 And th = 0 Then
part4 = ""
Else
part4 = "Thousand "
End If
If h = 0 Then
part5 = ""
Else
part5 = array1(h) & "Hundred "
End If
If t = 0 And o < 1 Then
partand = ""
Else: partand = "and "
End If
If amount < 100 Then
partand = ""
End If
If t = 0 Then
part6 = ""
ElseIf t = 1 Then
part6 = array2(t + o)
Else
part6 = array3(t)
End If
If amount < 1 Then
part7 = "No "
ElseIf o = 0 Or t = 1 Then
part7 = ""
Else
part7 = array1(o)
End If
DollarsToText = part1 & part1and & part2 & part3 & part4 & part5 & partand & _
part6 & part7 & "Dollar(s) and " & C & " cents"
End Function