View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
mudraker
 
Posts: n/a
Default hot key for background color


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
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=544035