Convert numeric value into text

First problem -

Convert numeric value into text

Convert currency value into words.

e.g. Rs. 10,000 would become Rupees Ten Thousand Only

Rs 1,50,749.77 would become Rupees One Lakh Fifty Eight Thousand Seven Hundred Forty Nine And Seventy Seven Paise Only.


Second Problem -

=IFERROR(IF($A16>=$K$1,(INDEX(($L$1:$L$40),MATCH($B16,($H$1:$H$40),0))),IF($A16< =$I$1,(INDEX(($J$1:$J$40),MATCH($B16,($H$1:$H$40),0))))),0)

this formula works in Microsoft excel but displays error while being used in numbers (iwork).

In numbers formula only considers first part. While giving equation for second part it gives result as FALSE. And while using in numbers last 0 and bracket have to be removed to get result. if not removed formula displays error.


Regards

Nishat Gupta

MacBook Pro, OS X El Capitan (10.11.6)

Posted on Aug 3, 2016 10:30 AM

Reply
12 replies

Aug 3, 2016 7:23 PM in response to Nishat gupta

Hi Nishat,


First question needs a lookup table for the translation. I did one several years ago for AppleWorks, and later for Numbers '09. Will take a look for it tonight.

I think either SGIII or Wayne Contello did one earlier as well. Both were for English/north American names and number formats, so a direct copy might not be sufficient.


Second question:

Lots of extra parentheses in there! They're not needed to enclose the H1:H40 range type references. Won't make it not work, but they do add noise when a human is trying to ead the formula.


Here's an example using the addresses in your formula, but omitting the IFERROR part as I wanted to see the actual results, including errors, if any.

User uploaded file

The formula below is from U16. The one under the image is in U17.


IF($A16≥$K$1,INDEX($L$1:$L$21,MATCH($B16,$H$1:$H$21,0)),IF($A16≤$I$1,INDEX($J$1: $J$21,MATCH($B16,$H$1:$H$21,0)),1))


In the selected cell (U17) the tests in both IF statements return FALSE, so the FALSE result for the second is what is returned.


To add an IFERROR:


=IFERROR(formula above,0)


Regards,

Barry

Aug 3, 2016 6:53 PM in response to Nishat gupta

here is a refined variation of what I have previously provided:


download the compressed file from the following link:

https://www.dropbox.com/s/3ep5eiute4t629z/NumWriterWithScripts.zip?dl=0


double click this file to expand it to a folder with a few files (listed here):

User uploaded file

To use this, copy the files NumToWords.scpt AND NumWrite to the scripts folder for Numbers.

1) Launch Numbers

2) Select the menu item "Scripts > Open Scripts Folder > Open Numbers Scripts Folder":

User uploaded file


3) Drag the two files mentioned earlier (NumToWords.scpt AND NumWrite) to the Numbers script folder


4) confirm you placed the files in the correct folder by checking the path to this image of my path by holding the command key while clicking the folder name in the title of the window (start the comparison at your user folder... min is "wayne"):

User uploaded file



In Number, enter some numeric values (integers) in a column... like this and select the column of numbers:

User uploaded file


Now, while that column is selected, select the new script from the scripts menu:

User uploaded file


After, you will see the words appear in the next column:

User uploaded file

Aug 4, 2016 10:04 AM in response to Wayne Contello

Hi Wayne

Thanks for providing the solution.

I did try to follow the steps but could not proceed further as i have never used script (Script Editor) before. I am totally unaware how the script application works. I was unable to locate menu item scripts in numbers & numbers scripts folder. It would be great help if you could guide me through it.


Regards

Nishat

Aug 4, 2016 5:03 PM in response to Nishat gupta

Nishat gupta wrote:


I am totally unaware how the script application works. I was unable to locate menu item scripts in numbers & numbers scripts folder.


Writing scripts can be complicated but using scripts like this one is typically really easy, just a matter of clicking a menu button or making a menu choice. But you first have to get things set up on your machine (a one-time, easy task). If you don't see the scripts menu go to Script Editor > Preferences > General and make sure that 'Show Script menu in menu bar' is checked:


User uploaded file


Also make sure Script Editor.app is checked at System Preferences > Security & Privacy > Privacy > Accessibility.


Then follow Wayne's instructions. If you have trouble just post again.


(If you're not doing this often you can also run the script right from Script Editor by clicking the triangle 'run' button rather than installing the script in the menu).


SG

Aug 4, 2016 6:49 PM in response to Wayne Contello

Hello Wayne


I was able to work out this time and was successful in converting numbers to text. While using it i faced a problem. If context is cell is changed the converter displays results of previous transaction. What i need is formula which automatically converts without running script every time. I am using a formula in macro enabled excel file. the module is as follows -


OptionExplicit


' Function for conversion of a Currency to words

' Parameter - accept a Currency

' Returns the number in words format

'*************************************


Function CTW(ByVal MyNumber)

Dim Temp

Dim Rupees, Paisa As String

Dim DecimalPlace, iCount

Dim Hundred, WORDs As String

ReDim Place(9) AsString

Place(0) = " Thousand "

Place(2) = " Lakh "

Place(4) = " Crore "

Place(6) = " Arab "

Place(8) = " Kharab "

OnErrorResumeNext

' Convert MyNumber to a string, trimming extra spaces.

MyNumber = Trim(Str(MyNumber))

' Find decimal place.

DecimalPlace = InStr(MyNumber, ".")

' If we find decimal place...

If DecimalPlace > 0 Then

' Convert Paisa

Temp = Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2)

Paisa = " and " & ConvertTens(Temp) & " Paisa"

' Strip off paisa from remainder to convert.

MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))

EndIf


' Convert last 3 digits of MyNumber to rupees in word.

Hundred = ConvertHundred(Right(MyNumber, 3))

' Strip off last three digits

MyNumber = Left(MyNumber, Len(MyNumber) - 3)


iCount = 0

Do While MyNumber <> ""

'Strip last two digits

Temp = Right(MyNumber, 2)

If Len(MyNumber) = 1 Then

WORDs = ConvertDigit(Temp) & Place(iCount) & WORDs

MyNumber = Left(MyNumber, Len(MyNumber) - 1)

Else

WORDs = ConvertTens(Temp) & Place(iCount) & WORDs

MyNumber = Left(MyNumber, Len(MyNumber) - 2)

End If

iCount = iCount + 2

Loop


CTW = "Rupees " & WORDs & Hundred & Paisa & " Only."

EndFunction


' Conversion for hundred

'*************************************...

Private Function ConvertHundred(ByVal MyNumber)

Dim Result AsString


' Exit if there is nothing to convert.

If Val(MyNumber) = 0 Then Exit Function

' Append leading zeros to number.

MyNumber = Right("000" & MyNumber, 3)

' Do we have a hundred place digit to convert?

If Left(MyNumber, 1) <> "0" Then

Result = ConvertDigit(Left(MyNumber, 1)) & " Hundred "

End If

' Do we have a tens place digit to convert?

If Mid(MyNumber, 2, 1) <> "0" Then

Result = Result & ConvertTens(Mid(MyNumber, 2))

Else

' If not, then convert the ones place digit.

Result = Result & ConvertDigit(Mid(MyNumber, 3))

End If

ConvertHundred = Trim(Result)

EndFunction


' Conversion for tens

'*************************************...

Private Function ConvertTens(ByVal MyTens)

Dim Result AsString


' Is value between 10 and 19?

If Val(Left(MyTens, 1)) = 1 Then

Select Case Val(MyTens)

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

EndSelect

Else

' .. otherwise it's between 20 and 99.

Select Case Val(Left(MyTens, 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

EndSelect

' Convert ones place digit.

Result = Result & ConvertDigit(Right(MyTens, 1))

EndIf

ConvertTens = Result

EndFunction


Private Function ConvertDigit(ByVal MyDigit)

Select Case Val(MyDigit)

Case 1: ConvertDigit = "One"

Case 2: ConvertDigit = "Two"

Case 3: ConvertDigit = "Three"

Case 4: ConvertDigit = "Four"

Case 5: ConvertDigit = "Five"

Case 6: ConvertDigit = "Six"

Case 7: ConvertDigit = "Seven"

Case 8: ConvertDigit = "Eight"

Case 9: ConvertDigit = "Nine"

Case Else: ConvertDigit = ""

EndSelect

EndFunction


I have tried to implement same in numbers but couldn't as numbers doesn't support macro. Please help if possible. Thanks


Regards

Nishat

Aug 5, 2016 5:37 AM in response to Nishat gupta

Nishat gupta wrote:


What i need is formula which automatically converts without running script every time. I am using a formula in macro enabled excel file. the module is as follows -



Numbers does have "macros" in the sense that AppleScript (which is external to Numbers and other apps) can do similar things to VBA. However, in Numbers you cannot code user-defined functions the way you can in Excel. In Excel I rarely use UDF's anyway, because they are such resource hogs, often noticeably slowing performance.


Triggering an AppleScript is quite easy: just a menu pick or a keyboard shortcut.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Convert numeric value into text

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.