Keyboard Shortcut to Toggle between Various Formats (e.g. font & fill color, numbering)

BIGDOG123

New Member
Joined
Sep 1, 2016
Messages
8
I am building some shortcuts into excel and am wondering how do I make a keyboard shortcut that can toggle between different formats. I would like to create several toggles highlighted below and hopefully more thereafter:

- Toggle Between Colors with “Cntrl + Shift + C” (Blue, Green, Red)
- Toggle Between Fill Color with “Cntrl + Shift + Y” (Yellow, Grey, Beige)
- Toggle Between Number Formats with “Cntrl + Shift + N” (Number, Currency, Percent, Multiple(ie: 5.0x ) )

Also, when I create my own keyboard shortcuts, I cannot press “Cntrl + Z” to undo them. Is there something I can do to the code to allow me to press “Cntrl + Z” to undo my keyboard macros. For example, assuming I can get the above to work, If I press “Cntrl + Shift + C” to get a black cell to turn blue, then I would like to be able to press “Cntrl + Z” to undo it back to black if necessary.
 
When I run this macro, a message box appears and it says the following, "Active cell's font color is 0, Active cell's interior color is 16777215, vb blue is 16711680, vb green is 65280 and vb red is 255.
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
So, your cell is currently formatted for black font and white background. The code I provided previously would toggle between blue, green, and red... but, since you're starting from white (or black, if you've changed .interior to .font), you're not hitting the blue --> green --> red --> blue loop.

Assuming you're OK to start with blue, change "Case vbRed" to "Case Else" in the code and you'll have blue --> green, green --> red, and anything else (red, white, etc) --> blue.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top