Align Center

Rather than merging cells to center headers, I prefer to have text centered across selection. This avoids problems with deleting and filling columns that are cosed by merged cells. The following sets up a command to toggle centering across columns.

Open up the AppleScript Editor, paste the following code and save it as /Users/<your-username>/Documents/Microsoft User Data/Excel Script Menu Items/AlignCentered\sca.scpt. The \sca in the filename creates a keyboard shortcut control-shift-a.

-- Align selected cells across selection
-- Copyright under GPL by Mark Grimes
-- Saving with '\sca' in the filename creates Shortcut: Crtl+Shift+a

tell application "Microsoft Excel"
	--activate
	tell range (get address selection) of active sheet
		if (get count columns) > 1 or (get count rows) > 1 then
			if (get horizontal alignment) is horizontal align center across selection then
				set horizontal alignment to horizontal align general
			else
				set horizontal alignment to horizontal align center across selection
			end if
		else
			if (get horizontal alignment) is horizontal align center then
				set horizontal alignment to horizontal align general
			else
				set horizontal alignment to horizontal align center
			end if
		end if
	end tell
end tell

Comments:

Post your comment

All comments are held for moderation; basic HTML formatting accepted.

(required) (required, not published) (optional)


Published

01 March 2010

Tags

Iron Man Status


Weak, I know...

License

The contents of this blog are licensed under the Creative Commons “Attribution-Noncommercial-Share Alike 3.0″ license.