Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Capturing what tab was selected

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MicroMain - 25 Jan 2006 04:09 GMT
I have a macro that is invoked when leaving a tab (deactivate), to
clear off some data and do some other functions on that sheet, before
moving to other sheets.

I want to capture the tab that was selected, and then at the end of the
macro, auto select the sheet that they clicked.

Can someone please give me the command for capturing the clicked sheet?

Thanks
Ken Johnson - 25 Jan 2006 04:26 GMT
Is that Rick?
ActiveSheet.Name returns the name of the worksheet whose tab was
clicked, deactivating the Sheet with the Worksheet_deactivate code.
Ken Johnson
Ken Johnson - 25 Jan 2006 04:58 GMT
Your code must be reactivating the original sheet, otherwise it would
automatically end up on the sheet whose tab was clicked.
Here's a bit of code residing in the sheet1 module that places the
clicked sheet's name in a string variable (strClickedSht), throws up a
MsgBox with the clicked sheet's name, reactivates Sheet1, selects A1 on
Sheet1 then activates the Sheet whose tab was clicked.

Private Sub Worksheet_Deactivate()
Dim strClickedSht As String
strClickedSht = ActiveSheet.Name
MsgBox ActiveSheet.Name
Sheet1.Activate
Sheet1.Range("A1").Select
Application.EnableEvents = False
Worksheets(strClickedSht).Activate
Application.EnableEvents = True
End Sub

Ken Johnson
MicroMain - 25 Jan 2006 05:10 GMT
Thanks again Ken,

I've put the code (without the Msg box stuff) into the macro and it
works Marvelously.

Thanks

You are 'da Man
Ken Johnson - 25 Jan 2006 05:33 GMT
Hi Rick,
That's good news.
Keep up the good work.
Ken Johnson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.