LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional Formatting in Excel Help Please..... Willie T Excel Discussion (Misc queries) 4 February 9th 05 02:28 PM
Effect of Conditional Formatting, Data Validation Bill Sturdevant Excel Discussion (Misc queries) 1 January 25th 05 11:50 PM
Copy conditional formatting across multiple rows? Gil Excel Discussion (Misc queries) 1 January 11th 05 11:27 AM
Determine cells that drive conditional formatting? Nicolle K. Excel Discussion (Misc queries) 2 January 7th 05 01:08 AM
Conditional formatting not available in Excel BAB Excel Discussion (Misc queries) 2 January 1st 05 03:33 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"