Shortcut to change the font color in the cell

Myurathan

New Member
Joined
Mar 7, 2013
Messages
4
I'm working on a sheet. i should have blue and black font colors random. if i can have macro shortcut for blue and black, would save loads of my time. please help me on this.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Greg Hitchon

New Member
Joined
Mar 6, 2013
Messages
38
Hi,

Macros to change cell colors are not a problem, but I am not quite sure what you are asking for.

Do you mean you want all cells (or a certain range) randomly coloured either blue or black? Or do you want a shortcut key that would change the colour of the selected cell/range to blue/black?
 

Myurathan

New Member
Joined
Mar 7, 2013
Messages
4
Hi!
shortcut key that would change the colour of the selected cell/range to blue/black. simply saying a keyboard shortcut key for fontcolor blue and black..
 

Greg Hitchon

New Member
Joined
Mar 6, 2013
Messages
38
So a simple way of doing this goes as follows:


Code:
'Run this once before using, it is just to set the shortcuts (you can do this manually as well but for ease of use this is simpler)
Sub SetShortcutKeys()
With Application
.OnKey key:="^+K", Procedure:="turn_Black"              'CTRL+SHIFT+K--turn cell black
.OnKey key:="^+L", Procedure:="turn_Blue"               'CTRL +SHIFT+L--turn cell blue
End With
End Sub

'this will turn the entire selection black...this is not undoable so be careful
Sub turn_Black()

    Selection.Interior.Color = vbBlack
End Sub


Sub turn_Blue()
    Selection.Interior.Color = vbBlue
End Sub

so run the "SetShortCutKeys" sub, and then you can use:
CTRL+SHIFT+K--turn cell black
CTRL+SHIFT+L--turn cell blue
 

Myurathan

New Member
Joined
Mar 7, 2013
Messages
4

ADVERTISEMENT

Thanks a lot for your help, but i need to change the font color. the macro changes the cell color :(.
 

Greg Hitchon

New Member
Joined
Mar 6, 2013
Messages
38
Ah, sorry misread.

Change the "Interior" bit to "Font" as shown:

Rich (BB code):
Sub turn_Black()
    Selection.Font.Color = vbBlack
End Sub


Sub turn_Blue()
    Selection.Font.Color = vbBlue
End Sub
 

Myurathan

New Member
Joined
Mar 7, 2013
Messages
4
Thanks a lot. it works charm. one quick question, is that possible that what ever the workbook i'm working on, can i use this macro without creating it again and again? i mean use this macro on all work books.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,194
Messages
5,768,776
Members
425,492
Latest member
blueexcel123

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
Top