Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Seed numbers for random number generation, uniform distribution | Excel Discussion (Misc queries) | |||
Sorting when some numbers have a text suffix | Excel Discussion (Misc queries) | |||
Sorting imported "numbers" | Excel Discussion (Misc queries) | |||
To find a combination of numbers that equal a set amount? | Excel Discussion (Misc queries) | |||
words and numbers in an IF function | Excel Discussion (Misc queries) |