highlighting a row

P

praptisahni

is there a way to highlight a row depending upon where i am, fo
instance if i am on cell C24 then the entire row 24 should b
highlighted and so on
i understand that it may not be possible to achieve this, so is ther
any addin avalible which achieves this resul
 
B

Bob Phillips

Hi Prapti,

I like this solution which was posted a couple of days ago

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sRow As String

Cells.FormatConditions.Delete

With Target.EntireRow
sRow = .Address
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=1=1"
.FormatConditions(1).Interior.ColorIndex = 35
End With

End Sub

It is worksheet event code, so on the target worksheet right-click the sheet
tab, select View Code, and paste the code in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

Jeremy

SHIFT+Spacebar selects the entire row you are in.

CTRL+Spacebar select the entire column you are in.
 
D

Don Guillett

Right click sheet tab>view code>copy paste this.
If you only want the active cell take out .entirerow

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo endit
Cells.Interior.ColorIndex = 0
ActiveCell.EntireRow.Interior.ColorIndex = 6
endit:
Application.EnableEvents = True
End Sub
 
D

David McRitchie

Hi Jeremy,
note that the following wipes out all interior cell color
Cells.Interior.ColorIndex = 0

A method less likely to cause problems is one that
changes the cell border color.
See Chip Pearson's "RowLiner"
http://www.cpearson.com/excel/rowliner.htm updated 2004-03-13
which is more popular, but like any macro you lose the ability
to undo (ctrl+z) which is a heavy price to pay if this isn't
really going to make much of a difference to you..

You will notice that when you select a cell
that the column letter and the row number get shaded,
and the cell address usually appears in the name box,
unless it is a named range.
 
Top