开发者

How do you make a macro in excel not show the selections being made

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?


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.


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"

Here's a good introductory article on this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜