View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve Steve is offline
external usenet poster
 
Posts: 1,814
Default Formatting via VBA

Hi gang
I am trying to use this code to achieve grreater than 3 condition CF.

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:a100")) Is Nothing Then
With Target
Select Case LCase(.Value)
Case "Case1": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 3
Case "Case2": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 5
Case "Case3": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 10
Case "Case4": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 19
Case "Case5": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 20
Case "Case6": .Offset(0, 1).Resize(1, 7).Interior.ColorIndex = 34
End Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


2 Questions...

1 How can I add and AND to the case? IE., Case1 is "Dog" and 0. (I want to color only cells that are greater than 0.)

2 The formatting is on a report that is not updated except by links to another Sheet. Neither change event or calculate event as I see it will really work in this instance without having to go back and over type the values in A1:A100. Can I adapt the code so I can assign it to a button and run it from there, without having to go overtype all of the values A1:A100?

Thanks!
Steve