Home |
Search |
Today's Posts |
#6
![]() |
|||
|
|||
![]()
One way to do it is check to see if the changed cell is in one of those ranges:
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim myRngB As Range Dim myRngCD As Range Dim myRngH As Range Dim myRngMNO As Range If Target.Cells.Count 1 Then Exit Sub Set myRngB = Me.Range("B:B") Set myRngCD = Me.Range("C:D") Set myRngH = Me.Range("H") Set myRngMNO = Me.Range("M:O") If Not (Intersect(Target, myRngB) Is Nothing) Then 'do the work for column B ElseIf Not (Intersect(Target, myRngCD) Is Nothing) Then 'do the work for C:D ElseIf Not (Intersect(Target, myRngH) Is Nothing) Then 'do the work for H ElseIf Not (Intersect(Target, myRngMNO) Is Nothing) Then 'do the work for M:O End If End Sub ========== But since your ranges are complete columns, you could even make it look like: Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub Select Case Target.Column Case Is = 2 'do the work for B Case Is = 3, 4 'do the work for C:D Case Is = 8 'column H Case Is = 13, 14, 15 'columns M, N, 0 End Select End Sub The "do the work" stuff will look a lot like the previous posts. David Flick wrote: Dave Peterson allegedly wrote in : Like this??? [snip] I changed your "select case" statement so that I only had to look at lower case "numbers"??? Dave, This seems to be just a bit faster than the routine I was using when the worksheet gets to be a few MB in size. Since I am a bit (very) weak on VBA I wonder if you might set me straight on another question? What I would like to do is evaluate multiple conditions in different ranges. i.e. 1) Column B has a numeric value I would like to color code based on content. Values are 1 through 6. 2) Columns C and D has four digit numeric values to evaluate for conditional formatting. 3) Column H has an alpha-numeric value to evalute for conditional formatting. 4) Columns M, N, and O have single character codes to evaluate for conditional formatting. I have tried copying the Sub down and changing what I thought were the relevant components, but alas have not been able to fudge it along sufficiently well to make it work as yet. Dave Flick -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Formatting in Excel Help Please..... | Excel Discussion (Misc queries) | |||
Effect of Conditional Formatting, Data Validation | Excel Discussion (Misc queries) | |||
Copy conditional formatting across multiple rows? | Excel Discussion (Misc queries) | |||
Determine cells that drive conditional formatting? | Excel Discussion (Misc queries) | |||
Conditional formatting not available in Excel | Excel Discussion (Misc queries) |