Reputation: 1
Some of your folks advocate not using ActivateSheet. So how do I get the name of the active worksheet?
Upvotes: 0
Views: 76
Reputation: 3845
You could use Selection.Parent.Name
However, that is even worse.
One reason to not use Selection
or ActiveSheet
is that while debugging, you might inspect other sheets or select other cells, and if you then continue with F5 or F8, you will work on other data than foreseen.
But if the action taken by your code SHOULD depend on which sheet is currently active, just use ActiveSheet
. (If you need it at the end of a Subroutine, or if you need it twice, however, consider assigning it to a variable at the beginning.
Upvotes: 1