Excel选择与激活 [英] Excel Select vs Activate
问题描述
VBA代码 wb.Sheets(1).Cells.Select
和 wb.Sheets(1).Activate
?
选择之间的区别是您可以一次选择几个对象。所选择的对象也放置在可以使用方法的Selection对象中。除非您选择多个对象,否则选择(例如,单元格)将激活对象。
激活只是使对象成为活动对象。
想法的最佳方式是可以选择许多单元格,但在任何给定时间只有一个可能是活动单元格。
$ b $注意:他们都有一个共同点 - 他们很少需要,他们通常不做任何事情,但减慢你的代码。您可以在不选择或激活对象的情况下直接在对象上工作,除非需要,否则最好不要使用这些对象。
What is the difference between the VBA code wb.Sheets(1).Cells.Select
and wb.Sheets(1).Activate
?
Difference between select is that you can select several objects at once. Objects that are selected are also placed in the Selection object which you can use methods on. Unless you are selecting multiple objects, selecting (say, a cell) activates the object.
Activate just simply makes the object the active object. Best way to think of it is "many cells can be selected, but only one may be the active cell at any given time."
Note: They both have one thing in common - they are rarely ever needed and they do generally don't do anything but slow your code down. You can work directly on an object without selecting or activating it and it's best practice not to use these unless needed.
这篇关于Excel选择与激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!