Re: hot key for background color

Giganews Newsgroups
Subject: Re: hot key for background color
Posted by:  mudraker (
Date: Sun, 21 May 2006

Try this

On a normal module sheet you will code similar to this

Option Explicit

Public iColour As Integer

Sub Macro1()
' Keyboard Shortcut: Ctrl+Shift+R
iColour = 3 'red
End Sub

Sub Macro2()
' Keyboard Shortcut: Ctrl+Shift+Y
iColour = 6 ' yellow
End Sub

Sub Macro3()
' Keyboard Shortcut: Ctrl+Shift+B
iColour = 0 ' no colour
End Sub

On the worksheet module you will need

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> "" Then
With Target.Interior
..ColorIndex = iColour
..Pattern = xlSolid
End With
End If
End Sub

The Worksheet_Change macro will be trigged for every cell entry so it
will change the backgroud colour even when you edit an entry in a cell

mudraker's Profile:
View this thread:



In response to

hot key for background color posted by Fecozisk on Sat, 20 May 2006