Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sick of writting the text expression of a numeric value?
this function change this: 15196739.32 Into this: FIFTEEN MILLION ONE HUNDRED NINETY SIX THOUNSAND SEVEN HUNDRED THIRT NINE Is up to you if you want to use the function, and how to add it to yo worksheet Function Number2Text(Number) a1a19 = Array("ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN" "EIGHT", "NINE", "TEN", "ELEVEN", "TWELVE", "THIRTEEN", "FOURTEEN" "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINETEEN") aDecenas = Array("", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY" "SEVENTY", "EIGHTY", "NINETY") aLlones = Array("THOUNSAND", "MILLION", "BILLION", "TRILLION" "QUADRILLION", "QUINTILLION", "SEXTILLION", "SEPTILLION", "OCTILLION" "NONILLION", "DECILLION", "UNDECILLION", "DUODECILLION" "TREDECILLION") Number = Str(Number) Pos = InStr(Number, ".") If (Pos 0) Then Number = Left(Number, Pos - 1) If (Val(Number) = 0) Then Text = "ZERO " Else millon = 0 Do Number = "000" + LTrim(Number) 'Zeros to left to crop smooth de1a99 = Val(Right(Number, 2)) If (de1a99 0) And (de1a99 < 20) Then Text = a1a19(de1a99 - 1) + " " + Text Else unidad = Val(Right(Number, 1)) If (unidad 0) Then Text = a1a19(unidad - 1) + " " + Text decena = Val(Left(Right(Number, 2), 1)) If (decena 0) Then Text = aDecenas(decena - 1) + " " + Text End If centena = Val(Left(Right(Number, 3), 1)) If (centena 0) Then Text = a1a19(centena - 1) + " HUNDRED " Text Number = Left(Number, Len(Number) - 3) If (Val(Number) 0) Then Text = aLlones(millon) + " " + Text millon = millon + 1 End If Loop While ((Number 0) And (millon < 14)) End If Number2Text = Text End Function I did 2 more functions, one to handle the cents and other with just th Format as default parameter. Function Number2Currency(Number, Frm) Cents = Right(Format(Number, "#.00"), 2) Text = Number2Text(Number) If Frm < "" Then Frm = Replace(Frm, "%", Cents) End If Number2Currency = "(" + Text + Frm + ")" End Function Function Number2Dollar(Number) Number2Dollar = Number2Currency(Number, "DOLLARS %/100 U.S.C.Y.") End Function About the function, i take the arrays from credits to him. Greetings Robert -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Data Validation/Lookup function does function correcty | Excel Worksheet Functions | |||
copy of excel file not showing formulal/function in the function b | Excel Discussion (Misc queries) | |||
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) | Excel Worksheet Functions | |||
Offset function with nested match function not finding host ss. | Excel Worksheet Functions | |||
User-Defined Function pre-empting Built-in Function? How to undo???? | Excel Programming |