Questions and Answers on Excel Macros
Topic: Is ActiveSheet in ThisWorkbook?
Is there a way to check if ActiveSheet is part of the workbook in which
the a macro is located?
I have a macro which switches between 3 open workbooks, and for some
reason the activesheet also switches...
How to check if ActiveSheet is in ThisWorkbook or in ActiveWorkbook?
Indeed the ActiveSheet is always in the ActiveWorkbook because both are visible on screen.
ThisWorkbook is the workbook within which the macro runs and the ActiveSheet is not necessarily in ThisWorkbook.
To check such a fact use an if statement:
If ActiveWorkbook.Name=ThisWorkbook.Name then.....
To learn everything about all these workbooks and how to move from one to the other see lesson 14 of my Downloadable Course on Excel Macros
To send your questions or comments click here
Back to Q&A on Excel Macros