View Single Post
  #5   Report Post  
Bob Phillips
 
Posts: n/a
Default Auto color-shading of rows


"Fitz" wrote in message
. ..
Doesn't seem to be working. Can't explain. I'm working in Excel 2003.

If
I
right click the worksheet thats relevant to the request (it's also the one
maximized), I get the option to "View Code". If I then left-click "View
Code", I end up in Microsoft Visual Basic and I have a window for sheet 1
which contains two drop-down boxes: The left one has (General) and
Worksheet as the 2 dropdown choices and the right one has 10 choices
including selectionchange and activate, to name two. Where specifically
should I paste this


Just paste the code into the big blank area of the window that shows. The
dropdowns can be ignored here.

and does it effect only that sheet or all other sheets
as well in that workbook. I only want it to effect one worksheet in the
workbook. I also don't want it to be run as regular code in other

workbooks
every time I open excel.


I gave you code for a single sheet first time, then for all sheets after
your follow-up question.
If you want just one sheet, you have the wrong code, use this version
instead

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 436: .EntireRow.Interior.ColorIndex = 6
Case 437: .EntireRow.Interior.ColorIndex = 5
'etc
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub