ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change numeric value to words (https://www.excelbanter.com/excel-programming/273774-change-numeric-value-words.html)

JOHN

Change numeric value to words
 
Is there any function (both vba or worksheet) I can use to change numeric
value to words? For example, it can tell 'one thousand and ten' for the
number 1010.



Orlando Magalhães Filho

Change numeric value to words
 
Hi John,

Look for "VBA spell numbers function" at this site:
http://cpap.com.br/orlando


HTH

---

(So that you get best and rapid solution and all may benefit from the
discussion, please reply within the newsgroup, not in email)


"JOHN" escreveu na mensagem
...
Is there any function (both vba or worksheet) I can use to change numeric
value to words? For example, it can tell 'one thousand and ten' for the
number 1010.





Eddy[_3_]

Change numeric value to words
 
Check out this web site:-

http://www.ozgrid.com/VBA/ValueToWords.htm

"JOHN" ¼¶¼g©ó¶l¥ó ...
Is there any function (both vba or worksheet) I can use to change numeric
value to words? For example, it can tell 'one thousand and ten' for the
number 1010.





losmac

Change numeric value to words
 
This is it!
It was in other language, so change and complete code to your language.

Option Explicit
Dim Idziesiatka

Function SLOWNIE(ByVal Numer)
Dim temps, tempd, tempj, zlote, grosze, Licznik, grd, grj, MiejsceDz,
T_S

If Numer = 0 Then
SLOWNIE = "zero $ zero "
Exit Function
End If

If Numer 9999999999999.99 Or Numer < 0 Then
MsgBox "Function convert corectly only values between 0 to
9999999999999,99"
SLOWNIE = "bad range"
Exit Function
End If

Numer = Trim(Str(Numer))
MiejsceDz = InStr(Numer, ".")

If MiejsceDz 0 Then
grosze = Left(Mid(Numer, MiejsceDz + 1) & "00", 2)
grd = Dziesiatki(Right(grosze, 2))
If Idziesiatka < 1 Then
grj = Jednostki(Right(grosze, 1))
End If
grosze = " " & grd & grj & "gr"
Numer = Trim(Left(Numer, MiejsceDz - 1))
Else
grosze = " zero gr"
End If

If Numer < "" Then
Licznik = 1
Do While Numer < ""
temps = ""
tempd = ""
tempj = ""
temps = Setki(Right("000" & Numer, 3))
tempd = Dziesiatki(Right("00" & Numer, 2))
If Idziesiatka < 1 Then
tempj = Jednostki(Right(Numer, 1))
End If

Select Case Licznik
Case 1: T_S = temps & tempd & tempj
Case 2: T_S = temps & tempd & tempj & KTys(Numer)
Case 3: T_S = temps & tempd & tempj & KMil(Numer, Licznik)
Case 4: T_S = temps & tempd & tempj & KMil(Numer, Licznik)
Case 5: T_S = temps & tempd & tempj & KMil(Numer, Licznik)
End Select
zlote = T_S & zlote

If Len(Numer) 3 Then
Numer = Left(Numer, Len(Numer) - 3)
Licznik = Licznik + 1
Else
Numer = ""
End If
Loop
Else
zlote = "zero "
End If
SLOWNIE = zlote & "$" & grosze
End Function

Public Function KTys(ByVal Numer)
Dim tys
tys = Val(Right("000" & Numer, 3))
If tys = 0 Then
KTys = ""
Else
tys = Val(Right(Numer, 2))
If tys = 1 Then
KTys = "tousend"
Else
If tys = 12 Or tys = 13 Or tys = 14 Then
KTys = "s "
Else
tys = Val(Right(Numer, 1))
Select Case tys
Case 2, 3, 4: KTys = "s "
Case Else: KTys = "s "
End Select
End If
End If
KTys = "thousand" & KTys
End If
End Function

Public Function KMil(ByVal Numer, L)
Dim mil
Dim RzadW(5) As String
RzadW(3) = "million"
RzadW(4) = "milliard"
RzadW(5) = "billion"
mil = Val(Right("000" & Numer, 3))
If mil = 0 Then
KMil = ""
Else
mil = Val(Right(Numer, 2))
If mil = 1 Then
KMil = " "
Else
If mil = 12 Or mil = 13 Or mil = 14 Then
KMil = "s "
Else
mil = Val(Right(Numer, 1))
Select Case mil
Case 2, 3, 4: KMil = "s "
Case Else: KMil = "s "
End Select
End If
End If
KMil = RzadW(L) & KMil
End If
End Function


Public Function Setki(ByVal Numer)
Dim setka, wynik
setka = Val(Left(Numer, 1))
Select Case setka
Case 1: wynik = "houndred " '100
Case 2: wynik = "two houndred " '200
Case 3: wynik = " houndred " '300
Case 4: wynik = " houndred " '400
Case 5: wynik = " houndred " '500
Case 6: wynik = " houndred " '600
Case 7: wynik = " houndred " '700
Case 8: wynik = " houndred " '800
Case 9: wynik = " houndred " '900
End Select

Setki = wynik
End Function

Public Function Dziesiatki(ByVal Number)
Dim wynik
Idziesiatka = Val(Left(Number, 1))
If Idziesiatka = 1 Then

Select Case Val(Number)
Case 10: wynik = "ten "
Case 11: wynik = " "
Case 12: wynik = " "
Case 13: wynik = " "
Case 14: wynik = " "
Case 15: wynik = " "
Case 16: wynik = " "
Case 17: wynik = " "
Case 18: wynik = " "
Case 19: wynik = " "
End Select

Else

Select Case Idziesiatka
Case 2: wynik = " " '20
Case 3: wynik = " " '30
Case 4: wynik = " " '40
Case 5: wynik = " " '50
Case 6: wynik = " " '60
Case 7: wynik = " " '70
Case 8: wynik = " " '80
Case 9: wynik = " " '90
End Select
End If

Dziesiatki = wynik

End Function

Public Function Jednostki(ByVal Numer)
Dim jedst, wynik
jedst = Val(Right(Numer, 1))
Select Case jedst
Case 1: wynik = "one "
Case 2: wynik = "two "
Case 3: wynik = " "
Case 4: wynik = " "
Case 5: wynik = " "
Case 6: wynik = " "
Case 7: wynik = " "
Case 8: wynik = " "
Case 9: wynik = " "
End Select
Jednostki = wynik
End Function


U¿ytkownik "JOHN" napisa³ w wiadomo¶ci
...
Is there any function (both vba or worksheet) I can use to change numeric
value to words? For example, it can tell 'one thousand and ten' for the
number 1010.





Gary Simpson

Change numeric value to words
 
http://support.microsoft.com/default...NoWebContent=1

Regards,

Gary Simpson

Tom Ogilvy

Change numeric value to words
 
I did some tinkering with the code to insert "and" where necessary


You have to be careful with insertion of the word AND. For example saying

one hundered and thirty-five dollars is incorrect.

it should be one hundered thirty-five dollars

This is a fairly common error.

--
Regards,
Tom Ogilvy

"Cecilkumara Fernando" wrote in message
...
John, Ken Write post this sometime back.
I did some tinkering with the code to insert "and" where necessary
can send that code on request
Cecil

Hi Ayush, The following is a nice comprehensive answer compiled by Norman
Harker.

You should try a Google search for questions as you might imagine that

this
is a fairly common question.

See:

XL2000: How to Convert a Numeric Value into English Words
http://support.microsoft.com/default...EN-US;Q213360&

and:

XL: How to Convert a Numeric Value into English Words
http://support.microsoft.com/default...EN-US;q140704&

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 he

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).


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

This file might be a help:
http://www.bygsoftware.com/examples/...s/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, finally:



A post containing a UDF by Bernie Deitrick that will take you into US

budget
territory by covering amounts into trillions.
"JOHN" wrote in message
...
Is there any function (both vba or worksheet) I can use to change

numeric
value to words? For example, it can tell 'one thousand and ten' for the
number 1010.








All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com