Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.setup
|
|||
|
|||
Condional Formatting with MACRO
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 |
#2
Posted to microsoft.public.excel.setup
|
|||
|
|||
Condional Formatting with MACRO
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 |
#3
Posted to microsoft.public.excel.setup
|
|||
|
|||
Condional Formatting with MACRO
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 |
#4
Posted to microsoft.public.excel.setup
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.setup
|
|||
|
|||
Condional Formatting with MACRO
Thanks bob, I figured it out..
thanks a lot, it helped Kudos to u "Bob Phillips" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help combining formatting in macro functions | Excel Worksheet Functions | |||
how do I email amacro? | Excel Worksheet Functions | |||
Conditional Formatting in Macro | Excel Discussion (Misc queries) | |||
Compiling macro based on cell values | Excel Discussion (Misc queries) | |||
Search, Copy, Paste Macro in Excel | Excel Worksheet Functions |