Highlight Active Row

norts55

Board Regular
Joined
Jul 27, 2012
Messages
184
Hello Everyone,
I have an older spread sheet that has a lot of columns and it is hard to follow the same row from one side to the other. Doing a web search, I found code to highlight the active row in excel. This pretty much does what I want but the problem is, the undo and redo functions seem to not be active when I am using this code. Does anyone know how to modify this code to keep the undo and redo or does anyone have other code that will gives this result but keeps the undo and redo functions active? Maybe there is a better way all together, I am open to anything. Thanks in advance.


Here is the link where the code:



VBA Code:
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

Static xRow

If xRow <> "" Then
    With Rows(xRow).Interior
        .ColorIndex = xlNone
    End With
End If

Active_Row = Selection.Row
xRow = Active_Row
With Rows(Active_Row).Interior
    .ColorIndex = 8
    .Pattern = xlSolid
End With

End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
The method I typically use is to add the following to the sheet where you want the active row/col highlighted:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Application.CutCopyMode = False Then
On Error Resume Next
Application.Calculate
End If
End Sub

Then set up conditional formatting for the affected range using the following formula and setting a fill color:
=OR(CELL("COL")=COLUMN(),CELL("row")=ROW())
 
Upvote 0
Solution

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top