vba 你如何在excel中制作宏不显示正在进行的选择
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3558519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you make a macro in excel not show the selections being made
提问by Behrooz Karjoo
I know there's a property to add in the beginning of the macro so that all the selections and deselection happen in the background and are not shown on the sheet. I think I had to disable some property at the beginning of the macro and enable it at the end. Does anyone remember what it was?
我知道有一个属性要添加到宏的开头,以便所有选择和取消选择都在后台进行,并且不会显示在工作表上。我想我必须在宏开始时禁用某些属性并在最后启用它。有人记得那是什么吗?
回答by Gabriel McAdams
This is what you're looking for:
这就是你要找的:
Application.ScreenUpdating = False
Just remember to call this
记得叫这个
Application.ScreenUpdating = True
at the end (and make sure you have error handling. If it fails and you do not set it back to true, the application will appear to be frozen forever.
最后(并确保您有错误处理。如果它失败并且您没有将其设置为 true,应用程序将永远被冻结。
回答by e100
Best practice would be to avoid working with selections altogether.
最佳做法是完全避免使用选择。
Other than to initially determine which cell/object the user wants to carry out an action on, you just refer directly to the objects you need to.
除了最初确定用户想要对其执行操作的单元格/对象之外,您只需直接引用您需要的对象。
To give a very simple example, instead of
举一个非常简单的例子,而不是
Range("G18").Select
ActiveCell.Value = "123"
You use
你用
Range("G18").Value = "123"