View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
L. Howard Kittle L. Howard Kittle is offline
external usenet poster
 
Posts: 698
Default Macro to select / highlight entire row.

Hi Ross,

Try this in the worksheet Module. Right click the sheet tab and select View
Code, copy and paste in the large white area.

Select any cell between A2 to Z25 and note the highlighting. Can be
modified to a different range size and a color of choice.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Data As Range
Dim i As Integer
Dim k As Integer
i = 1
k = ActiveCell.Column()
Set Data = Range("A2:Z25")

Data.Interior.ColorIndex = xlNone

If ActiveCell.Row < 2 Or ActiveCell.Row 25 Or _
ActiveCell.Column < 1 Or ActiveCell.Column 26 Then
Exit Sub
End If

ActiveCell.Offset(0, -(k - i)). _
Resize(1, 26).Interior.ColorIndex = 35

End Sub

HTH
Regards,
Howard

"Ross" wrote in message
...

How can I get Excel to select an entire row when I use the "Arrow UP" key
or
the "Arrow Down" key?

For Example, if the cursor has selected Cell A3 and I "Arrow Down" to A4,
the cursor would then select the ENTIRE A4 ROW (this spreadsheet has data
in
some of the A:Z columns (columns are not consistently filled for all cell
A4:Z4).

This will help the viewer see all of the A4:Z4 cells highlighted (kind of
a
custom user input aid).

Many Thanks

Ross