LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Conditional formatting code that looks up a list of criteria

Hi All
I'm using Excel 2007, I have a brilliant conditional formatting code that
applies conditional formatting to a column of data that contains 40 different
product names.

The code looks at strings in $C$95:$C$300 (user enters any text but always
includes the product name somewhere). When it finds the product name it
colours the cell for that product.

My problem is that new product codes will need be added to the list.
I'd like the user to be able to add new products to the list and the code
pick up those new products and include them in the conditional formatting.

Can the code use a list of product names for it's criteria instead of having
each product name specifically entered into the code?

e.g. (Current code)
For Each Cell In Range("$C$95:$C$300")
If Cell.Value Like "*MOL Summer Bundle C*" Then
'(can the above step lookup the next product name (somewhere within a
*string*) in the product list and use that as the criteria instead of having
to quote the actual name "*MOL Summer Bundle C*"?)

The "product name" list appears in the the current worksheet - range
$Z$74:$Z$114.

Current Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Range("$C$95:$C$300")
If Cell.Value Like "*MOL Summer Bundle C*" Then
Cell.Interior.Color = vbRed
ElseIf Cell.Value Like "*Autumn Bundle A*" Then
Cell.Interior.Color = vbBlue
ElseIf Cell.Value Like "*Gold*" Then
Cell.Interior.Color = vbGreen
End If
Next Cell
End Sub

I would also like to thank all the Microsoft experts for all the help they
provide in this discussion group. It is absolutely invaluable to novice
users like me who are trying to learn and automate manual tasks.
--
Cheers
BeSmart
 
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 2 criteria in one row gimpy Excel Discussion (Misc queries) 3 May 18th 09 06:00 PM
Conditional formatting for many criteria Ruth Excel Discussion (Misc queries) 2 October 10th 08 09:54 PM
Conditional Formatting of 4 criteria gibsol Excel Discussion (Misc queries) 10 October 6th 08 10:22 AM
CONDITIONAL FORMATTING FOR MORE THAN 3 CRITERIA FARAZ QURESHI Excel Discussion (Misc queries) 1 February 12th 08 09:35 AM
need help with conditional formatting 3 criteria [email protected] Excel Worksheet Functions 2 November 10th 06 12:55 PM


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

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

About Us

"It's about Microsoft Excel"