Share via

Undo Function no longer operational after adding VBA Code

Anonymous
2024-08-27T12:49:24+00:00

Hi!

I recently followed this excellent tutorial (Click Here) for how to get excel to highlight the row I actively have selected ( I made some minor changes in the conditional formatting, so that it only highlights certain columns in certain rows). However, the undo function no longer works (It's just totally grayed out). I've done some searching on the internet and this seems to be a known issue (seems to be that it's a problem to undo after vba code has executed changes to a sheet, so it clears the undo stack) but I haven't really found a solution.

Is is possible to have the highlighting of the row when selected AND retain the ability to undo?

My understanding of coding and vba is very limited. I understand enough to google what I want excel to do, find someone else's existing code, and add it to my own workbooks (maybe make some very minor changes or adjustments). VBA is on my to do list to learn, I promise. but for now, the more simple the explanation the better.

Thank you so much <3

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Rory Archibald 18,965 Reputation points Volunteer Moderator
2024-08-27T14:17:26+00:00

Rather than using a named range, use CELL("row") in the formulas and/or CELL("column") if you need to check that too. Then the selection change code only needs to make Excel calculate, which should not clear the undo stack - eg:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Application.CutCopyMode = False Then

On Error Resume Next

Application.Calculate

End If

End Sub

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rory Archibald 18,965 Reputation points Volunteer Moderator
    2024-08-27T15:08:17+00:00

    You're welcome. :)

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-08-27T14:48:30+00:00

    OH MY GOD!!!!! This worked! You are AMAZING

    Thank you a million!!!

    <3<3<3<3<3<3<3<3<3<3<3

    Was this answer helpful?

    0 comments No comments