ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Setting up and Configuration of Excel (https://www.excelbanter.com/setting-up-configuration-excel/)
-   -   Condional Formatting with MACRO (https://www.excelbanter.com/setting-up-configuration-excel/118321-condional-formatting-macro.html)

Anift

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

Bob Phillips

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




Anift

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





Bob Phillips

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







Anift

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








All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com