Basic AppleScript To Toggle Cell Formats?

S

schalliol

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel

I would like to create an AppleScript to simply change the highlighted cells to text format "#,##0.0_);(#,##0.0)" I would like to be able to do this with a keypress like command-shift-d or similar. I would think there'd be some sort of way to do that. Assuming this is possible, I'd like to make it toggle between common formats, like the VBA version below. It seems there ought to at least be a way to apply a pre-defined format. Any help would be greatly appreciated!

Sub CurrencyFormattingToggle()

If Selection.NumberFormat = "General" Then
Selection.NumberFormat = "#,##0.0_);(#,##0.0)"

ElseIf Selection.NumberFormat = "#,##0.0_);(#,##0.0)" Then
Selection.NumberFormat = "$#,##0.0_);($#,##0.0)"

ElseIf Selection.NumberFormat = "$#,##0.0_);($#,##0.0)" Then
Selection.NumberFormat = "#0.0x"

ElseIf Selection.NumberFormat = "#0.0x" Then
Selection.NumberFormat = "0.0%_);(0.0%)"

Else: Selection.NumberFormat = "General"

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top