Format Excel cell range to percentages?

HI,

Can someone help me figure out how to apply the Percentage cell style to a specific set of cells in Excel?

Or, if better/easier, how to get an Automator Workflow to do do this? The example workflows provided can format cells but not to percentages… at least not that I can figure out.

Thanks,
Cindy in Indy

Cindy, Is there some reason you can’t just click on the Excel button for % formatting, or even using excel VBA macro?

I have found that generally, if the task is wholly within a MS Office app, then the best automation solution is usually a VBA macro. It’s very easy to get started just by recording a macro with the steps you want to take in the MS app.

If this is part of a bigger task, please describe the larger task, and post any KM macro you have that is involved. See How to Share Both Image and Macro to Forum Directly from KM Editor.

Why? Automation! Isn’t that why we are all here? :grinning:

I have more than 100 Excel doc that with various cells that need formulas and formatting for importing into Indesign via data merge. I have gotten KM to insert the formulas but I na not sure how to chose the “Percentage” formatting.

Please post your KM macro so we can help.

In general, I would write an AppleScript to select and format the Excel cells, and then call that script from KM.

If you do a Google on "applescript excel 2011" you should find several examples to help you write the script. Of course, don't forget to look at the Excel Scripting Dictionary. In the Script Editor, goto File > Open Dictionary

Hey Cindy,

Automator workflows are slow and cumbersome.

It's better to use AppleScript when possible.

tell application "Microsoft Excel"
  tell range selection of active window
    # Example 1
    set number format to "#%"
    # Example 2
    set number format to "###.00%"
  end tell
end tell

* Tested with Excel 14.6.1 from Office 2011 on OSX 10.11.3.

If you're wanting a different range than the selection you need to be very specific about what you need.

-Chris

Thanks ccstone! You’re my savior. I have hundreds of Excel docs that need this script.

:grinning:

Cindy