D
DocBrown
Based on discussions, it's clear that running a macro via the
Worksheet_Change event wipes out the undo stack. But I'm finding that there
are limited things I can code that will not wipe the stack. For example, I
want the macro to do it's thing only when cells within certain ranges are
selected. So if I write code that just determines if the selected cells are
within the range of interest, then the undo stack is left alone if no cells
in the range are selected.
My question is this: is there some list or information that tells me what
can be executed without wiping the undo?
I would imagine that anything that changes cell contents would wipe the
stack. But I'm finding even calling functions that only manipulate local
variables or objects causes a wipe.
Any insights on this?
Thanks,
John
P.S. here's the code in case it helps. In this code, the intersect call
causes the wipe. Even without that, there is code in the FillAcctCode macro
would cause it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intsecCatSubcat As Range
Dim currRow As Range
Dim colCategory As Long
Application.EnableEvents = False
colCategory = Range("CatSubcatCols").Column
If Target.Column + Target.Columns.Count - colCategory > 0 And _
colCategory - Target.Column + 1 >= 0 And _
Target.Row >= Me.Range("ExpenditureTable").Cells.Row Then
Set intsecCatSubcat = Application.Intersect(Target,
Me.Range("CatSubcatCols"))
FillAcctCode intsecCatSubcat
GetUniqueAccts
End If
GoTo ExitThisSub
ErrThisSub:
' place holder for error handling when it becomes needed.
ExitThisSub:
Application.EnableEvents = True
End Sub
Worksheet_Change event wipes out the undo stack. But I'm finding that there
are limited things I can code that will not wipe the stack. For example, I
want the macro to do it's thing only when cells within certain ranges are
selected. So if I write code that just determines if the selected cells are
within the range of interest, then the undo stack is left alone if no cells
in the range are selected.
My question is this: is there some list or information that tells me what
can be executed without wiping the undo?
I would imagine that anything that changes cell contents would wipe the
stack. But I'm finding even calling functions that only manipulate local
variables or objects causes a wipe.
Any insights on this?
Thanks,
John
P.S. here's the code in case it helps. In this code, the intersect call
causes the wipe. Even without that, there is code in the FillAcctCode macro
would cause it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim intsecCatSubcat As Range
Dim currRow As Range
Dim colCategory As Long
Application.EnableEvents = False
colCategory = Range("CatSubcatCols").Column
If Target.Column + Target.Columns.Count - colCategory > 0 And _
colCategory - Target.Column + 1 >= 0 And _
Target.Row >= Me.Range("ExpenditureTable").Cells.Row Then
Set intsecCatSubcat = Application.Intersect(Target,
Me.Range("CatSubcatCols"))
FillAcctCode intsecCatSubcat
GetUniqueAccts
End If
GoTo ExitThisSub
ErrThisSub:
' place holder for error handling when it becomes needed.
ExitThisSub:
Application.EnableEvents = True
End Sub