AppleScript Numbers: Formatting cells for currency - with options?

Environment: Mojave, Numbers 6.1, Automator 2.9, Both Numbers and Automator are set via System Preferences > Security & Privacy > Accessibility


I know I can format a cell for currency with:

set the format of myCell to currency


What I want to know, and haven't been able to discover yet, is how to add the options of:

  • "Thousands Separator"
  • "Accounting Style"


Or, perhaps alternatively, how to specify a custom format such as:


Name: MyAccounting

Type: Number

If the rules below aren't met: -.#

Rule 1: If greather than or equal to 0: $#,###0.00

Rule 2: If less than 0: ($#,###0.00)


Again, I've searched the web but was unable to find any examples of how to define and use a custom format in AppleScript.


The only thing I've seen is where I have to make sure I have one cell explicitly formatted the way I want and then do something (I didn't track all the details yet) to copy-style / paste-style, but that just seems a bit hack-ish. I'm hoping to find a cleaner solution.


MacBook Air 13", macOS 10.14

Posted on Jul 14, 2019 6:34 AM

Reply
6 replies

Jul 14, 2019 3:09 PM in response to SGIII

Hmm, seems a bit like an omission / missing feature...

For now I just [re-] formatted all the cells after running my script to populate everything. Since it's mostly static data I don't really have to worry about it too much.

I'll think about setting up the source-format-cell with copy/paste-format code sometime down the road.


Thanks for letting me know so I don't spend too much time trying to find it ;-)

Jul 15, 2019 7:44 AM in response to SGIII

Thanks for the suggestion - I just submitted it.


Interestingly, I actually found a way to get almost what I want - by changing my initial cell formula (that gets replaced with the resultant value) from


=SUMIFS(...)


to


=DOLLAR(SUMIFS(...))


This does the Thousands Separator and Accounting Style - parentheses around negative numbers, BUT the '$' is snug to the number instead of being left-justified while the digits are right-justified (the entire string is left-justified). So it's closer, but not quite "right"

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.

AppleScript Numbers: Formatting cells for currency - with options?

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