Highlight Cell MXXX

sachavez

Active Member
Joined
May 22, 2009
Messages
469
Excel 2007

I'm looking for some VBA that will highlight the cell in Column M of the row that I am working in.

Example, if I am working in row 35, cell M35 would be highlighted in pink. If I jump to row 1005, cell M1005 would be highlighted in pink.

Is this possible?

Thanks, in advance
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Select column M, go to Conditional Formatting, Formula Is, use the 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
Another option (with slightly different results) that may be of interest is to not have Conditional Formatting in the column but have this SelectionChange code

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_SelectionChange(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    Columns("M").Interior.ColorIndex = xlNone<br>    Intersect(Target.EntireRow, Columns("M")).Interior.ColorIndex = 38<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


The difference is if you select a range containing multiple rows, or even a disjoint range like H5:H8 and J12:K15. Not sure if that's better or worse for your circumstance.
 
Upvote 0
Peter,

Both options work like a champ. I'm definately going to use one or both of these options going forward.

Thanks again!

Steve
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,256
Members
452,901
Latest member
LisaGo

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