ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is ActiveSheet in ThisWorrkbook? (https://www.excelbanter.com/excel-programming/445098-activesheet-thisworrkbook.html)

Charlotte E.[_3_]

Is ActiveSheet in ThisWorrkbook?
 
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?


Thanks,

CE


Jim Cone[_2_]

Is ActiveSheet in ThisWorrkbook?
 
The active sheet is always in the active workbook.
--
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(List Files XL add-in: finds and lists files/folders with hyperlinks)


"Charlotte E."
wrote in message
...
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?


Thanks,

CE




Jim Cone[_2_]

Is ActiveSheet in ThisWorrkbook?
 
More...
You do not have to activate a workbook in order to run code.
"Workbooks(2).Sheets(3).Range("A1").value2 = 1234" runs just fine without activating/selecting that
workbook.

If you do have to determine if the workbook with code is active then...
"ActiveSheet.Parent Is ThisWorkbook" returns True or False.
'---
Jim Cone


"Jim Cone"
wrote in message
...
The active sheet is always in the active workbook.
--
Jim Cone
Portland, Oregon USA .
http://www.mediafire.com/PrimitiveSoftware .
(List Files XL add-in: finds and lists files/folders with hyperlinks)





"Charlotte E."
wrote in message
...
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?


Thanks,

CE






Pierre Leclerc[_3_]

Is ActiveSheet in ThisWorrkbook?
 
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.....

See all about these workbooks in my tutorial at www.excel-vba.com

Peter


simpleMacros

Is ActiveSheet in ThisWorrkbook?
 
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.....


All times are GMT +1. The time now is 04:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com