When switching from one worsheet to another worksheet (within the same workbook), which is the preferred/correct way to switch,
Sheets("sheet name").Select or
Sheets("sheet name").Activate?
Hi Shawn
You don't usually use select/activate objects in vba, as you already know. It's unnecessary and hurts code readability and performance.
Just to make it clear, however, and since you asked, it's not always the same thing to Select and to Activate.
In your case since you are just selecting/activating one only object, it will have the same effect using one or the other.
If you were dealing with a group of objects, however, it would not be the same thing.
Select: selects a group of objects and activates the first one in the group.
Activate: if the object is not yet selected, selects it before activating it. If the object is already selected, simply activates it, does not change the selection.
Example.
Let's say you select the range("A1:B3"). This causes 6 cells to be selected and the first one, A1, to be the active cell.
Now you want to keep the selection, but you want the cell B1 to be the active cell. In this case you'll use Activate on B1. After the statement is executed B1 will be the active cell but all the 6 cells will still be selected.
The same with worksheets. You can select Sheet1 and Sheet2 and then make Sheet2 active while keeping both selected.