Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old December 11th 04, 04:37 PM
ron
 
Posts: n/a
Default Amount or Numbers in Words

Hi,

Thanks for the two replies. However I found out that excel spells fifty
cents - and fifty cents only, is there any way I can remove the word "and".
Also, will it be possible to spell 1234.56 to One thousand two hundred thirty
four and cents fifty six only? I have to do in this format dur to cheques.
Thanks again.



  #2   Report Post  
Old December 20th 04, 06:33 PM
PJF
 
Posts: n/a
Default

Ron,

First check the following MS Excel article at:
http://support.microsoft.com/kb/q213360/

You don't have to be familiar with writing VBA code. Just copy the code
below and follow the instructions above the code field in the MS article
using standard copy and paste functions (Ctrl-C; Ctrl-V). Don't be
intimidated; it's no sweat. Save the file. Then go back to your worksheet
and type into the desired cell the formula =SpellNumber(xxx.xx). It will
spell out the text of that number. You can also use the function
=SpellNumber(XN), where (XN) is a cell containing a number in standard
format.

I've modified MS' VBA code given in the article to do what I THINK you're
asking such that $1234.56 results in One thousand two hundred thirty four
fifty six. Did you want to put "Cents" ahead of the .56? If so, that can
also be done.

Note: the original lines in the MS VBA code for this function that were
modified are preceded by a hyphen (') and have been left in the code but are
not active.

Let me know. Any other questions, don't hesitate to ask.

Regards,

PJF



"ron" wrote in message
...
Hi,

Thanks for the two replies. However I found out that excel spells fifty
cents - and fifty cents only, is there any way I can remove the word

"and".
Also, will it be possible to spell 1234.56 to One thousand two hundred

thirty
four and cents fifty six only? I have to do in this format dur to cheques.
Thanks again.




How to Create the Sample Function Called SpellNumber
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 Dollars, Cents, 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 cents and set MyNumber to dollar amount.
If DecimalPlace 0 Then
Cents = 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 Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
'Dollars = "No Dollars"
Dollars = " "

Case "One"
Dollars = "One "
Case Else
'Dollars = Dollars & " Dollars "
Dollars = Dollars & ""
End Select
Select Case Cents
Case ""
'Cents = " and No Cents"
Cents = " No"
Case "One"
'Cents = " Cents 01"
Cents = " One"
Case Else
'Cents = " and " & Cents & " Cents"
Cents = " " & Cents
End Select
SpellNumber = Dollars & Cents
End Function

' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) < "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) < "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function

' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function



  #3   Report Post  
Old December 20th 04, 09:24 PM
PJF
 
Posts: n/a
Default

BTW, the instructions from MS say to "type in" the code. That's not
necessary. Just copy and paste the code in the VBA module.

PJF


"PJF" wrote in message
...
Ron,

First check the following MS Excel article at:
http://support.microsoft.com/kb/q213360/

You don't have to be familiar with writing VBA code. Just copy the code
below and follow the instructions above the code field in the MS article
using standard copy and paste functions (Ctrl-C; Ctrl-V). Don't be
intimidated; it's no sweat. Save the file. Then go back to your

worksheet
and type into the desired cell the formula =SpellNumber(xxx.xx). It will
spell out the text of that number. You can also use the function
=SpellNumber(XN), where (XN) is a cell containing a number in standard
format.

I've modified MS' VBA code given in the article to do what I THINK you're
asking such that $1234.56 results in One thousand two hundred thirty four
fifty six. Did you want to put "Cents" ahead of the .56? If so, that can
also be done.

Note: the original lines in the MS VBA code for this function that were
modified are preceded by a hyphen (') and have been left in the code but

are
not active.

Let me know. Any other questions, don't hesitate to ask.

Regards,

PJF



"ron" wrote in message
...
Hi,

Thanks for the two replies. However I found out that excel spells fifty
cents - and fifty cents only, is there any way I can remove the word

"and".
Also, will it be possible to spell 1234.56 to One thousand two hundred

thirty
four and cents fifty six only? I have to do in this format dur to

cheques.
Thanks again.




How to Create the Sample Function Called SpellNumber
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 Dollars, Cents, 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 cents and set MyNumber to dollar amount.
If DecimalPlace 0 Then
Cents = 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 Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
'Dollars = "No Dollars"
Dollars = " "

Case "One"
Dollars = "One "
Case Else
'Dollars = Dollars & " Dollars "
Dollars = Dollars & ""
End Select
Select Case Cents
Case ""
'Cents = " and No Cents"
Cents = " No"
Case "One"
'Cents = " Cents 01"
Cents = " One"
Case Else
'Cents = " and " & Cents & " Cents"
Cents = " " & Cents
End Select
SpellNumber = Dollars & Cents
End Function

' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) < "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) < "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function

' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function





  #4   Report Post  
Old December 21st 04, 03:31 PM
ron
 
Posts: n/a
Default

Hi PJF,

Really want to thank you for your suggested formula. I need the spellnumber
formula to be:
1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

will that be possible becoz the "and" word is at different places all the
time depending on the figure. The cents needs to be before the amount e.g
1234.56 = One thousand thirty four and cents fifty six only instead of behind
the 56.
Really thank you very much. Will be glad if you could help cos I will need
the formula very frequently in my workplace. Thanks in adv again.

"PJF" wrote:

Ron,

First check the following MS Excel article at:
http://support.microsoft.com/kb/q213360/

You don't have to be familiar with writing VBA code. Just copy the code
below and follow the instructions above the code field in the MS article
using standard copy and paste functions (Ctrl-C; Ctrl-V). Don't be
intimidated; it's no sweat. Save the file. Then go back to your worksheet
and type into the desired cell the formula =SpellNumber(xxx.xx). It will
spell out the text of that number. You can also use the function
=SpellNumber(XN), where (XN) is a cell containing a number in standard
format.

I've modified MS' VBA code given in the article to do what I THINK you're
asking such that $1234.56 results in One thousand two hundred thirty four
fifty six. Did you want to put "Cents" ahead of the .56? If so, that can
also be done.

Note: the original lines in the MS VBA code for this function that were
modified are preceded by a hyphen (') and have been left in the code but are
not active.

Let me know. Any other questions, don't hesitate to ask.

Regards,

PJF



"ron" wrote in message
...
Hi,

Thanks for the two replies. However I found out that excel spells fifty
cents - and fifty cents only, is there any way I can remove the word

"and".
Also, will it be possible to spell 1234.56 to One thousand two hundred

thirty
four and cents fifty six only? I have to do in this format dur to cheques.
Thanks again.




How to Create the Sample Function Called SpellNumber
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 Dollars, Cents, 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 cents and set MyNumber to dollar amount.
If DecimalPlace 0 Then
Cents = 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 Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
'Dollars = "No Dollars"
Dollars = " "

Case "One"
Dollars = "One "
Case Else
'Dollars = Dollars & " Dollars "
Dollars = Dollars & ""
End Select
Select Case Cents
Case ""
'Cents = " and No Cents"
Cents = " No"
Case "One"
'Cents = " Cents 01"
Cents = " One"
Case Else
'Cents = " and " & Cents & " Cents"
Cents = " " & Cents
End Select
SpellNumber = Dollars & Cents
End Function

' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) < "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) < "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function

' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function




  #5   Report Post  
Old December 24th 04, 01:05 AM
PJF
 
Posts: n/a
Default

Ron,

I'll work on modifying the code to see if I can get it to provide the
several formats the way you need them. Since I'm solidly snowed in, you
caught me at the right time! <g Give me a day or two.

Happy holidays to you.

PJF (In the "State of Emergency" midwest)


"ron" wrote in message
...
Hi PJF,

Really want to thank you for your suggested formula. I need the

spellnumber
formula to be:
1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

will that be possible becoz the "and" word is at different places all the
time depending on the figure. The cents needs to be before the amount e.g
1234.56 = One thousand thirty four and cents fifty six only instead of

behind
the 56.
Really thank you very much. Will be glad if you could help cos I will need
the formula very frequently in my workplace. Thanks in adv again.





  #6   Report Post  
Old December 24th 04, 03:38 AM
PJF
 
Posts: n/a
Default

Ron,

You sent me the following combos:

1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

Should there be an "only" after the 123?

PJF

"PJF" wrote in message
...
Ron,

I'll work on modifying the code to see if I can get it to provide the
several formats the way you need them. Since I'm solidly snowed in, you
caught me at the right time! <g Give me a day or two.

Happy holidays to you.

PJF (In the "State of Emergency" midwest)


"ron" wrote in message
...
Hi PJF,

Really want to thank you for your suggested formula. I need the

spellnumber
formula to be:
1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

will that be possible becoz the "and" word is at different places all

the
time depending on the figure. The cents needs to be before the amount

e.g
1234.56 = One thousand thirty four and cents fifty six only instead of

behind
the 56.
Really thank you very much. Will be glad if you could help cos I will

need
the formula very frequently in my workplace. Thanks in adv again.





  #7   Report Post  
Old December 24th 04, 07:32 PM
PJF
 
Posts: n/a
Default

Ron,

I'll need more info from you to try to give you the VBA code you'll need for
your project. To expedite doing so, please email me directly at my address
below.

PJF


"PJF" wrote in message
...
Ron,

You sent me the following combos:

1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

Should there be an "only" after the 123?

PJF

"PJF" wrote in message
...
Ron,

I'll work on modifying the code to see if I can get it to provide the
several formats the way you need them. Since I'm solidly snowed in, you
caught me at the right time! <g Give me a day or two.

Happy holidays to you.

PJF (In the "State of Emergency" midwest)


"ron" wrote in message
...
Hi PJF,

Really want to thank you for your suggested formula. I need the

spellnumber
formula to be:
1234.56 = One thousand thirty four and cents fifty six only
1234 = One thousand two hundred and thirty four only
123= One hundred and twenty three
0.12= Cents twelve only

will that be possible becoz the "and" word is at different places all

the
time depending on the figure. The cents needs to be before the amount

e.g
1234.56 = One thousand thirty four and cents fifty six only instead of

behind
the 56.
Really thank you very much. Will be glad if you could help cos I will

need
the formula very frequently in my workplace. Thanks in adv again.









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting when some numbers have a text suffix confused on the tundra Excel Discussion (Misc queries) 5 December 18th 04 10:19 PM
Sorting imported "numbers" Confused on the tundra Excel Discussion (Misc queries) 5 December 17th 04 07:33 PM
To find a combination of numbers that equal a set amount? Larry Morris Excel Discussion (Misc queries) 6 December 17th 04 05:39 PM
words and numbers in an IF function Spoony_13 Excel Discussion (Misc queries) 7 December 17th 04 03:29 AM
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 2 December 6th 04 05:01 PM


All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017