JamesCarter
JamesCarter

Reputation: 1

How do I find the name of the active worksheet without using ActiveSheet?

Some of your folks advocate not using ActivateSheet. So how do I get the name of the active worksheet?

Upvotes: 0

Views: 76

Answers (1)

Dirk Horsten
Dirk Horsten

Reputation: 3845

You could use Selection.Parent.Name However, that is even worse.

One reason to not use Selection or ActiveSheetis 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

Related Questions