Highlight row when click a cell in that row

mr names

New Member
Joined
Feb 11, 2011
Messages
14
Hi Guys

Basically I am running a gantt chart (critical path) in excel with dates across the top and tasks running down the left.

When i click in a cell on the critical path, I would like the row and column to highlight or change colour in some way so that it is easiier to see what task I am on?

Hope this makes sense
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi.

Select the area that you want this to apply to then use Conditional Formatting with the following formula

=ROW()=CELL("row")

and set a fill color.

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

then press ALT + Q to close the code window.
 
Upvote 0
Welcome to the Board!

This will do it, just be warned that it will wipe out any existing formatting, so like with all code examples, try it on a test workbook first:

<font face=Calibri><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> Excel.Range)<br>    Cells.Interior.ColorIndex = xlNone<br>    <SPAN style="color:#00007F">With</SPAN> ActiveCell<br>        .EntireRow.Interior.ColorIndex = 36<br>        .EntireColumn.Interior.ColorIndex = 36<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

EDIT: nevermind, Peter's is a much cleaner approach. :)
 
Upvote 0
That works perfect! Genious!

One last thing however...Is there a simple way of making it so that the column also changes colour? To give it an almost 'cross hairs' style?

:)
 
Upvote 0
Welcome to the Board!

This will do it, just be warned that it will wipe out any existing formatting, so like with all code examples, try it on a test workbook first:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Cells.Interior.ColorIndex = xlNone
With ActiveCell
.EntireRow.Interior.ColorIndex = 36
.EntireColumn.Interior.ColorIndex = 36
End With
End Sub



THanks Smitty! I'm working on a newly created version with no formatting so it's not replacing anything at present...Thanks for the reply though, much appreciated! :)
 
Upvote 0
Change the CF formula to

=OR(ROW()=CELL("row"),COLUMN()=CELL("col"))
 
Upvote 0

Forum statistics

Threads
1,215,688
Messages
6,126,208
Members
449,299
Latest member
KatieTrev

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