Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.....
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a password in VBA ActiveSheet.protect & ActiveSheet.unprotect? Jim K. Excel Programming 2 June 2nd 08 08:09 PM
Copying new activesheet after other activesheet is hidden? Simon Lloyd[_790_] Excel Programming 1 June 20th 06 10:02 AM
ActiveSheet Graham[_3_] Excel Programming 0 July 30th 03 09:08 AM
ActiveSheet Ron de Bruin Excel Programming 0 July 29th 03 04:59 PM
ActiveSheet Graham[_3_] Excel Programming 0 July 29th 03 04:47 PM


All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"