PDA

View Full Version : Excel shortcuts, keystrokes and related matters



rugila
04-03-2004, 01:59 PM
A few days ago somebody (roofus) wanted to know if there was a built-in keystroke in Excel to centre the cell contents (including text) in a cell.

I’m pretty sure that there is no built-in keystroke for this in Excel (although someone I was discussing a related matter with a while ago said “you can’t look into the mind of God”. The corollary being that you can only deduce their thoughts from their behaviour).

The reason seems to be that there’s so many functions that Excel can or does do that it’s not feasible to assign built in keystrokes to all or even many of them. On the other hand the developers of Excel have made it easy for users to assign their own keystrokes to whatever they like (usually operations they do frequently).

It does require however that your version of Excel has VBA (visual basic for applications) as an add-in (specifically with “Macro” being listed in the Tools menu.
Although the customer (roofus) left happy on that occasion, I include the following in case it may be of help to anyone else interested in this sort of thing.


Open blank workbook

Then Menus -> Tools -> Macro -> Record New Macro

Give the Macro a name, say centre, assign it a keystroke, say crtl+m, use default to store in personal macro workbook, and click OK

Then Menus -> Format -> Cells -> Alignment

Set Horizontal to Centre across selection, and set Vertical to Center (assuming you want the cell contents centred vertically)

Click OK

Then Menus -> Macro -> Stop Recording

Voila! Whatever cell or cells (if you select more than one) you select and hit keys ctrl m, the contents of the cell (or left hand cell) will be centred across the selected cell (or cells).

If you like you can as well have your selection formatted bold, in yellow (text or interior), or any other formatting you like with the same keystroke. It should be obvious enough from the above as to how to adjust the macro (or keystroke) so this is achieved.