本文介绍了运行VBA代码并保持Excels UNDO / REDO完好无损?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行这个代码强制更新几个图表:

I run this code to force update a few charts:

'Force update charts
For Each cht In Sheets("Charts").ChartObjects
    cht.Chart.SeriesCollection.Add Source:=Worksheets("Builder").Range("AI2:AI7")
    cht.Chart.SeriesCollection(cht.Chart.SeriesCollection.Count).Delete
Next cht

我不想撤消或重做从Excel快速访问栏下面的行。不幸的是,上面的行清除Excel的撤消/重做列表,我不能再撤消/重做更改。

I never want to undo or redo the lines below from the Excel quick access bar. Unfortunately the lines above clear Excels undo/redo list and I can no longer undo/redo changes.

是否可以使Excel撤消/重做忽略运行的VBA代码不能被清除?

Is it possible to make Excels undo/redo ignore the VBA code that runs and not be cleared?

推荐答案

YES

无论您在Excel中执行的任何操作电子表格存储在名为撤消列表的列表中。所以当您第一次执行撤消时,Excel会引用此列表,然后撤消您执行的最后一个操作。

Whatever action that you perform in Excel Spreadsheet is stored in a list which is called the Undo List. So when you do an Undo for the first time, Excel refers to this list and then Undoes the last action that you performed.

例如,以下将给您

Debug.Print Application.CommandBars("Standard").Controls("&Undo").List(1)

您可能希望在 Jan Karel Pieterse。

You might want to see this link on Creating An Undo Handler To Undo Changes Done By Excel VBA by Jan Karel Pieterse.

这篇关于运行VBA代码并保持Excels UNDO / REDO完好无损?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:44