Active Sheet

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Whats the easiest way to find out what sheet is "active"?

I need to get the name of the sheet the macro is run from for some
conditions in code however this is prooving harder then I thought. How
do I do this?

TIA
 
Scott,

Variable = ActiveSheet.Name.

I wouldn't however call this "the sheet the macro is run from" as the macro
can change the active sheet bij Sheet("name").activate.

An other possibility is that the macro was invoked by an event occuring on a
sheet (for instance a change taking place on that sheet by inpuuting a value
in a cell on that sheet). This however also just implies that that sheet
was the active one at the moment the macro started, but that could change
during the run of the macro (and by the macro itself).

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *
 
Scott,

If your macro is being called from clicking on a button on the sheet, then
you can use
ActiveSheet.name to determine it. The same is generally true for other
means of calling the macro (keyboard shortcut, toolbar button, etc.). Even
if more than one sheet is selected, only one can be active, and that will be
the one the user clicked a button on.
 

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

Back
Top