ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to check if workbook is the last one opened (https://www.excelbanter.com/excel-programming/291237-code-check-if-workbook-last-one-opened.html)

KimberlyC

Code to check if workbook is the last one opened
 
Hi

I need to run code from a command button that closes the Activeworkbook.
This code runs from an addin file.
I would like the code to check and see if the activeworkbook is the last
workbook open and if it is then code "a" will run and if not then code "b"
will run.

I'm not sure how to check to see if the active workbook is the last workbook
open.

Any help would be greatly appreciated.

Thanks in advance,
Kimberly



Bob Phillips[_6_]

Code to check if workbook is the last one opened
 
Kimberly,

Try

workbooks.Count

but be aware that there may be some hidden workbooks opened, such as
Personal.xls.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"KimberlyC" wrote in message
...
Hi

I need to run code from a command button that closes the Activeworkbook.
This code runs from an addin file.
I would like the code to check and see if the activeworkbook is the last
workbook open and if it is then code "a" will run and if not then code "b"
will run.

I'm not sure how to check to see if the active workbook is the last

workbook
open.

Any help would be greatly appreciated.

Thanks in advance,
Kimberly






All times are GMT +1. The time now is 08:48 AM.

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