Auto colour a range of of cells in active row

Sparky

Board Regular
Joined
Feb 18, 2002
Messages
210
Office Version
  1. 2010
Platform
  1. Windows
I have data in cells B14:O14 down to B33:O33. Could anyone help out by providing the code required to auto colour any row range from above when any cell from B14 to O14 is selected.

I am using 2003.

Thanks in advance
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Insert into sheet module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("B14:O14")) Is Nothing Then
        Range("B1:O13").Interior.ColorIndex = 16
    Else
        Range("B1:O13").Interior.ColorIndex = xlNone
    End If
End Sub
 
Upvote 0
Select B14:O33 and apply this Conditional Formatting formula

=ROW()=CELL("row")

and apply a fill colour. Right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks to both of you for your quick replies however, Sektor your code does not work, maybe its something to do with my range of data (B14:O33).

VoG

Your CF and code works perfectly. Thank you.
 
Upvote 0
You said "above". Above what? I assumed that it's out of your data range.
 
Upvote 0
Sektor

I have just re-read my question and it is misleading. I apologise for that. What I was referring to was my actual data range (B14:O33) and not everything above B14:O14.

Could you please provide your solution as a matter of interest.

Once again Thank You
 
Upvote 0
In B14:O33 it highlights all rows from B14:O14 till current row. Correct?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("B14:O33")) Is Nothing Then
        Range("B14:O" & Target.Row).Interior.ColorIndex = 6
    Else
        Range("B1:O33").Interior.ColorIndex = xlNone
    End If
End Sub
 
Upvote 0
Sektor

From my data range (B14:O33) I need to be able to select any cell from B14 to B33 and if for example I select B20 I would like B20:O20 only to be highlighted, not the data above or below. When I select another cell from B14 to B33 I would expect only the new selection to be highlighted.

Hope this helps

Thanks
 
Upvote 0
Then this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("B14:B33")) Is Nothing Then
        Range("B1:O33").Interior.ColorIndex = xlNone 'Remove prev coloring
        Range("B" & Target.Row & ":O" & Target.Row).Interior.ColorIndex = 6
    Else
        Range("B1:O33").Interior.ColorIndex = xlNone
    End If
End Sub
 
Upvote 0
Sektor

Perfect. Thanks for your persistance. It is the easier option.

Thanks to both Sektor & VoG.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,862
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top