Re : Numeric to alphbetical text

M

melvinc74

I want to convert a numeric value to alphabet equivalent eg: if there is
100 in cell A1,it should be converted to HUNDRED in cell A2.
 
N

Norman Harker

Hi melvinc74!

You should try a Google search for questions as you might imagine that
this
is a fairly common question.



Best answer is that you should download the Google Search 5.0 Addin
and User Guide from:



Ron de Bruin:

http://www.rondebruin.nl/Google.htm



But the answer that you are directly looking for is:



If you want numbers to be translated in Thai then there’s an Excel
function BAHTTEXT that will do it. For some reason Microsoft didn’t
think non-Thai speakers needed an equivalent. So:

See:

XL2000: How to Convert a Numeric Value into English Words
http://support.microsoft.com/default.aspx?scid=KB;EN-US;213360

and:

XL: How to Convert a Numeric Value into English Words
http://support.microsoft.com/default.aspx?scid=KB;EN-US;140704&

and:

(courtesy of a cut and paste from a Tom Ogilvy post):

If you want an addin that provides a worksheet function that does
this,
download Laurent Longre's free morefunc.xll addin found here:

http://longre.free.fr/english/

It is downloaded in a zip file which also contains an informative file
in
'hlp' format that describes the 33 or so very useful functions
included, one
of which does the number to words conversion you describe (supports
various
languages and currencies).



See also Laurent’s latest version that is multi-lingual.



http://longre.free.fr/tradnombre/NbText.zip

and:
(Courtesy of Andy Wiggins FCCA) of www.BygSoftware.com

This file might be a help:
http://www.bygsoftware.com/examples/zipfiles/num2wrds.zip

It's in the "Accountants" section on page:
http://www.bygsoftware.com/examples/examples.htm
It contains two methods to convert numbers to words and two check
writing
routines.

The code is open and commented.

And:

http://groups.google.com/[email protected]

A post containing a UDF by Bernie Deitrick that will take you into US
budget
territory by covering amounts into trillions.



And:



Orlando Magalhaes Filho (MVP)

http://cpap.com.br/orlando/#SpellNumber



A very flexible spell number function that allows, ordinary,
percentage and currency options.


--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
J

John Taylor

The following is about the best function I've found for converting numbers
to words. Unfortunately I'm not sure who the author is, but whoever it is,
thanks.

Cheers,

John

'Usage:
'With 123456.88 in Cell A1:
'=NumberToText(A1)
'returns "One Hundred Twenty-Three Thousand Four Hundred Fifty-Six and
Eighty-Eight"
'=NumberToText(A1,"Dollars","Cents")
'returns "One Hundred Twenty-Three Thousand Four Hundred Fifty-Six Dollars
and Eighty-Eight Cents"

'In the line -
' sDec = "and " & Trim(HundredsToText(CVar(sDec)) & " " & sCent)
' "and " can be changed to "point "
'so that =NumberToText(A1)
'returns "One Hundred Twenty-Three Thousand Four Hundred Fifty-Six point
Eighty-Eight"

Function NumberToText(Num As Variant, Optional vCurName As Variant, Optional
vCent As Variant) As Variant
Dim TMBT As Variant
Dim sNum As String, sDec As String, sHun As String, IC As Integer
Dim Result As String, sCurName As String, sCent As String

If Application.IsNumber(Num) = False Then
NumberToText = CVErr(xlValue)
Exit Function
End If

If IsMissing(vCurName) Then
sCurName = ""
Else
sCurName = Trim(CStr(vCurName))
End If

If IsMissing(vCent) Then
sCent = ""
Else
sCent = Trim(CStr(vCent))
End If

TMBT = Array("", "Thousand", "Million", "Billion", "Trillion",
"Quadrillion", "Quintillion", "Sextillion")

If IsMissing(sCent) Or IsNull(sCent) Then
sNum = Format(Application.Round(Num, 0), "0")
Else
sNum = Format(Application.Round(Num, 2), "0.00")
sDec = Right(sNum, 2)
sNum = Left(sNum, Len(sNum) - 3)
If CInt(sDec) <> 0 Then
sDec = "and " & Trim(HundredsToText(CVar(sDec)) & " " & sCent)
Else
sDec = ""
End If
End If

IC = 0
While Len(sNum) > 0
sHun = Right(sNum, 3)
sNum = Left(sNum, Application.Max(Len(sNum) - 3, 0))
If CInt(sHun) <> 0 Then
Result = Trim(Trim(HundredsToText(CVar(sHun)) & " " & TMBT(IC)) & " " &
Result)
End If
IC = IC + 1
Wend

Result = Trim(Result & " " & sCurName)
Result = Trim(Result & " " & sDec)
NumberToText = Result

End Function

Function HundredsToText(Num As Integer) As String
Dim Units As Variant, Teens As Variant, Tens As Variant
Dim I As Integer, IUnit As Integer, ITen As Integer, IHundred As Integer
Dim Result As String
Units = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine")
Teens = Array("Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen",
"Sixteen", "Seventeen", "Eighteen", "Nineteen")
Tens = Array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
"Seventy", "Eighty", "Ninety")
Result = ""
IUnit = Num Mod 10
I = Int(Num / 10)
ITen = I Mod 10
IHundred = Int(I / 10)

If IHundred > 0 Then
Result = Units(IHundred) & " Hundred"
End If

If ITen = 1 Then
Result = Result & " " & Teens(IUnit)
Else
If ITen > 1 Then
Result = Trim(Result & " " & Tens(ITen) & " " & Units(IUnit))
Else
Result = Trim(Result & " " & Units(IUnit))
End If
End If

HundredsToText = Result

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top