ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check active sheet not the one with macros (https://www.excelbanter.com/excel-programming/305517-check-active-sheet-not-one-macros.html)

OSCAR

Check active sheet not the one with macros
 
I have a workbook with macros that are used to process the
contents of other workbooks.

I need a test to ensure that when i run the macros the
active sheet belongs to a workbook other than the one with
the macros.

I don't know how. Any suggestions?

OSCAR

Check active sheet not the one with macros
 
Got It!

If ActiveWorkbook.Name = ThisWorkbook.Name Then
MsgBox "The source worksheet is not active. Bring
the source worksheet to the front and try again."
Exit Sub
End If


-----Original Message-----
I have a workbook with macros that are used to process

the
contents of other workbooks.

I need a test to ensure that when i run the macros the
active sheet belongs to a workbook other than the one

with
the macros.

I don't know how. Any suggestions?
.


Brian

Check active sheet not the one with macros
 
You could try the following:
Set a variable to the name of the workbook with the macros

MacroWkbkNm = ActiveWorkbook.Name 'Run when macro book is
active or set to something like "My Macro.xls"

Then, when you are testing whether the active sheet is in
the same workbook, you could only run code in another
workbook by using:

If ActiveWorkbook.Name < MacroWkbkNm Then
'Run code here
End If

-----Original Message-----
I have a workbook with macros that are used to process

the
contents of other workbooks.

I need a test to ensure that when i run the macros the
active sheet belongs to a workbook other than the one

with
the macros.

I don't know how. Any suggestions?
.



All times are GMT +1. The time now is 02:07 AM.

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