Workbook Deactivate event seems to occur too late

T

tbone

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top