Excel选择与激活 [英] Excel Select vs Activate

查看:88
本文介绍了Excel选择与激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆