Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Capturing what tab was selected

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Capturing what tab was selected

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Capturing what tab was selected

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Capturing what tab was selected

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Capturing what tab was selected

Hi Rick,
That's good news.
Keep up the good work.
Ken Johnson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing Top 5 Performers Questor Excel Worksheet Functions 5 April 18th 09 11:33 PM
capturing all of the data jimbo Excel Worksheet Functions 7 July 27th 08 06:10 PM
Capturing the selected tab in a worksheet_deactivate macro jkitzy Excel Programming 1 December 24th 04 09:01 PM
Capturing deletion of a row Glen Mettler[_4_] Excel Programming 3 December 12th 04 01:01 AM
Capturing user name Syed Faisal[_2_] Excel Programming 4 November 18th 03 05:59 PM


All times are GMT +1. The time now is 03:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"