Setting color of partial text to red in Excel

I would like to use AppleScript to set part of a text in a cell to red.
For example, a cell contain a text “This is IMPORTANT!”. I would like “IMPORTANT!” to be highlighted RED.

Any suggestions?


Hi qwork68,

If you want to change the color of a certain cell in Microsoft Office for Mac 2004/2008, you can use this AppleScript code:

tell application "Microsoft Excel"
	set color of font object of range "A1" of active sheet to {255, 0, 0}
end tell

Microsoft also offers an excellent and free Excel 2004 AppleScript Reference, which can also be used for the 2008 version.


try this, probably there’s a smarter solution

tell application "Microsoft Excel"
	tell cell "A1" of active sheet
		set value to "This is IMPORTANT"
		repeat with i from 9 to 17
			set color of font object of character i to {255, 0, 0}
		end repeat
	end tell
end tell

I knew it :slight_smile:

Thanks Jacques, range is the magic word