View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.setup
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Condional Formatting with MACRO

Sorry, missed an e

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "B:B"

If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
If Target.Cells.Count = 1 Then
If Target.Value = "Open" Then
Target.EntireRow.Interior.ColorIndex = 38
Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
End If
End If
End If

End Sub




--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Anift" wrote in message
...
Hello Bob,
Thanks for the response, i really appreciate..
But there is something wrong in this code

I am getting error on line " If Not Intersect(Target, rang(WS_RANGE)) Is
Nothing Then"
Its highlighing the word "rang",
Can we do anything about it?

any help will be appreciated.

Thanks


"Bob Phillips" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "B:B"

If Not Intersect(Target, rang(WS_RANGE)) Is Nothing Then
If Target.Value = "Open" Then
Target.EntireRow.Interior.ColorIndex = 38
Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
End If
End If

End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Anift" wrote in message
...
Hello all
I would like to hightlight a row based on a value in a cell. I know it

is
possible. I just don't know how to go about doing. i'd like to use vba

if
possible.
In Column B1 and down, I have open, close, etc. If Open is selected, I

would
like that row to be highlighted. Could someone help me out???

Thanks