One click row highlighting

D

Doug

I have a table. It would be very helpful if when I click on a cell in the
table that it highlight that particular row. I don't want it to highlight it
with a color or it will cover over the color conditional formatting I have,
but it would be great if it would show a box around it as though I selected
the entire row. Can this be done for one click only, as I have macros for
individual cells that are set for double click?
--
 
J

john

chip pearson has a very nice rowliner utility you can freely download.
http://www.cpearson.com/excel/RowLiner.htm

if that’s not you are looking for you could on a very simple level, use the
worksheet selection_change event to select the required range.

Something like this may do want – Paste behind appropriate worksheet &
change selection range as required:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Range("A1:F11")) Is Nothing = False Then

Range("A" & Target.Row & ":" & "F" & Target.Row).Select

End If

End Sub

Do remember though that you will have to use Tab key to step through
selected range to get to required cell(s).
 
D

Doug

Hey! This works great. I entered the range and all is well. I do have one
other question though. There is another private sub in the view code that is
also called Private Sub Worksheet_SelectionChange(ByVal Target As Range). It
said that there was an ambiguous error due to Worksheet_SelectionChange. I
tried changing the name so that they were not the same, but didn't work. Any
suggestions?
 
D

Doug

I have to take back what I said. It didn't work right. When I double click on
the cell with a hyperlink, the line selection is overriding it. I would
rather not download the rowliner utility, but I may try it if I can't get
this to work?

I appreciate your help.
 
J

john

You have answered your own question - procedure name already exits.

In that case just paste the code element in to the existing procedure i.e.
this bit:


If Intersect(Target, Range("A1:F11")) Is Nothing = False Then

Range("A" & Target.Row & ":" & "F" & Target.Row).Select

End If
 
J

john

try adding these lines in the Worksheet_BeforeDoubleClick event

Application.EnableEvents = False

'your code

Application.EnableEvents = True
 
R

Rick Rothstein

Give this Worksheet Change event a try (set the address for your table of
data in the Const statement in place of my "D4:H17" example address)...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const TableRangeAddress As String = "D4:H17"
Dim TableRange As Range
On Error GoTo Whoops
Application.ScreenUpdating = False
Set TableRange = Range(TableRangeAddress)
TableRange.Borders.LineStyle = xlLineStyleNone
If Intersect(Target, TableRange) Is Nothing Then Exit Sub
Intersect(Target.EntireRow, TableRange).BorderAround Weight:=xlMedium
Whoops:
Application.ScreenUpdating = True
End Sub
 
D

Doug

I just noticed that since I added this macro, when I click on a cell or enter
data, it clears the ability to undo recent changes to the sheet. Do you know
what might be causing this? Right now if I entered data or made changes that
I wanted to clear I would be in trouble because apparently it is not able to
keep a record of changes now.
 
D

Doug

Might you know why this is causing my undo to loose recent changes applied to
document? When I click a cell anywhere on the sheet, it cancels all
previously saved changes. If I need to undo a change, I won't be able to.
 
G

Gord Dibben

That is side-effect of running VBA code.

Undo stack is eliminated.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top