View Single Post
  #4   Report Post  
Fitz
 
Posts: n/a
Default Auto color-shading of rows

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 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.
In any case, I then copy and paste the code (as shown below) you've
provided in its entirety and press enter. When I then get back into Excel it
questions me about adjusting my security settings to allow a macro to run. I
do this but it still does not work. No hightlighting of lines as desired.
Any more advice or ideas would be greatly appreciated. Please be specific as
I'm in over my head when it comes to code and Microsoft VBA.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Column = 13 Then
With Target
Select Case .Value
Case 424: .EntireRow.Interior.ColorIndex = 6
Case 426: .EntireRow.Interior.ColorIndex = 35
Case 436: .EntireRow.Interior.ColorIndex = 41
Case "TAU": .EntireRow.Interior.ColorIndex = 45
'etc
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub