Hi all!
I have a macro button in user form that highlights column and row of selected cell. It is really useful, but it is kind of annoying to run it every time I need to use it. I know that I could set up a double click macro, but I don't want it to be active all the time (so I can double click sometimes without running macro).
So my 1st question - is it possible to create a button in user form that activates double click event, so then I can highlight cells using double click and then switch it off using the same or other button?
And if it is possible, then is there a way to adjust this macro below - right now it changes color of selection, but sometimes I have to use in worksheets with already colored cells and this macro overwrites current color. Can it be adjusted to only select column and row like this, instead of changing colors?
I have a macro button in user form that highlights column and row of selected cell. It is really useful, but it is kind of annoying to run it every time I need to use it. I know that I could set up a double click macro, but I don't want it to be active all the time (so I can double click sometimes without running macro).
So my 1st question - is it possible to create a button in user form that activates double click event, so then I can highlight cells using double click and then switch it off using the same or other button?
And if it is possible, then is there a way to adjust this macro below - right now it changes color of selection, but sometimes I have to use in worksheets with already colored cells and this macro overwrites current color. Can it be adjusted to only select column and row like this, instead of changing colors?
VBA Code:
Private Sub CommandButton7_Click()
Static xRow
Static xColumn
If xColumn <> "" Then
With Columns(xColumn).Interior
.ColorIndex = xlNone
End With
With Rows(xRow).Interior
.ColorIndex = xlNone
End With
End If
pRow = selection.Row
pColumn = selection.Column
xRow = pRow
xColumn = pColumn
With Columns(pColumn).Interior
.ColorIndex = 34
.Pattern = xlSolid
End With
With Rows(pRow).Interior
.ColorIndex = 34
.Pattern = xlSolid
End With