ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook Deactivate event seems to occur too late (https://www.excelbanter.com/excel-programming/438233-workbook-deactivate-event-seems-occur-too-late.html)

tbone[_2_]

Workbook Deactivate event seems to occur too late
 
Just curious, as this has bit me more than once.

Why is the Workbook Deactivate event fired *after* the ActiveWorkbook
has already been changed? It makes referencing cells in the
"deactivating" workbook unaddressable using simple Ranges. I've had to
resort to changing my code from this:

set llr = Range("LogLevel")

to this:

set llr = ThisWorkbook.Sheets("Support").Range("LogLevel")

in order to get and set data in the workbook being deactivated.
Besides being more complex of an expression, this would also be a
problem if needed to change the name of the sheet.

Anyone know why the event isn't fired *before* the ActiveWorkbook is
changed? Is there an easier or more general way to refer to ranges
that is immune to this issue? Can I specify a global named range in
another workbook (in this case, ThisWorkbook) without specifying the
sheet name?

What are best practices for referring to named ranges?

Thanks
tbone


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

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