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 PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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?
 
Upvote 0
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..
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

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