LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Conditional Formatting of Cell

one other thing, just in case there may not be a value in column D:

Select Case UCase(.Value)
Case "FAIL"
.Offset(, -1).Interior.ColorIndex = 3
Case "WATCH"
.Offset(, -1).Interior.ColorIndex = 19
Case "PASS"
.Offset(, -1).Interior.ColorIndex = 35
Case Else
.Offset(, -1).Interior.ColorIndex = 0
End Select

--


Gary

"Gary Keramidas" <GKeramidasAtMsn.com wrote in message
...
i don't always use conditional formatting unless i'm going to change data
between runs.

so, if you run your query and run code, something like this should work.

Sub test()
Dim i As Long
Dim ws As Worksheet
Dim lastrow As Long

Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row

For i = 1 To lastrow
With ws.Range("D" & i)
Select Case UCase(.Value)
Case "FAIL"
.Offset(, -1).Interior.ColorIndex = 3
Case "WATCH"
.Offset(, -1).Interior.ColorIndex = 19
Case "PASS"
.Offset(, -1).Interior.ColorIndex = 35
End Select
End With
Next

End Sub

--


Gary

"Dee" wrote in message
...
Hello, I have a worksheet whos data comes from SQL Server db. Autofilter
is
turned on. Within the worksheet are many columns. I would like to
change
the backcolor of the cells in column C based on the content of the
cell in column D (could be "PASS", "WATCH", or "FAIL") on the same row
(i.e. c1=5 d1='Pass' change backcolor of c1
to Green, or c1=7 d1='WATCH' change backcolor to Yellow, or c1=10
d1='FAIL'
change backcolor to Red). How do I identify the range and apply correct
backcolor to cells within range? Need to be coded using vba macro? --
DC

--
Dee





 
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--different formatting depending on cell con Tammy S. Excel Discussion (Misc queries) 3 March 30th 09 08:11 PM
Conditional formatting Based on cell A text with conditions in Cell B Raicomm Excel Discussion (Misc queries) 0 January 21st 08 04:46 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 3 January 20th 07 02:02 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 0 January 15th 07 04:35 PM


All times are GMT +1. The time now is 10:27 PM.

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"