Can selecting a tab trigger a macro?

vmottert

Board Regular
Joined
Aug 30, 2003
Messages
215
In my workbook, one tab ( SOA ) contains a lot of inventory. The next tab
( SOA_2 )contains a database extraction and displays only those records from SOA with " units > 0 ". The macro that does the extraction is now triggered by clicking on a button. This all works fine, but ... It would be a little more " idiot proof " if the extraction macro could be triggered every time the SOA_2 tab is selected. Can this be set up? If so, How?

Thanks in advance for any help with this.

Regards,

Vernon
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
Put your macro code in the WorkSheet Activate event.
Right click the Sheet tab, choose View code.
Paste your macro code in the panel that opens.
Change the Sub MacroName to:
Private Sub Worksheet_Activate()
 

vmottert

Board Regular
Joined
Aug 30, 2003
Messages
215
Thanks, guys. Thought I had seen that this was possible. I'll try it.

Regards,

Vernon
 

Watch MrExcel Video

Forum statistics

Threads
1,113,788
Messages
5,544,278
Members
410,601
Latest member
Silver2
Top