View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default automatically highlight a row when a cell in that row is selected


How about code that puts a border around the current row instead? This way,
if you have conditional formatting on your cells, the highlight will
cooperate with it. Give this a try. Right click the tab at the bottom of the
worksheet you want to have this functionality, select View Code from the
popup menu that appears and then copy/paste the following into the code
window that opened up...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo Whoops
Application.ScreenUpdating = False
Cells.Borders.LineStyle = xlLineStyleNone
Target.EntireRow.BorderAround Weight:=xlMedium
Whoops:
Application.ScreenUpdating = True
End Sub

--
Rick (MVP - Excel)


"Dave F" wrote in message
...
I imagine this is a pretty simple piece of VBA programming.

I want Excel to automatically highlight a row when I select a cell
from that row. For example, if I select G20, I want row 20 to be
highlighted, say, in yellow.

I'm using Excel 2007 and Windows XP if it matters.

Thanks for the help.