×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Call to run macro when shett activated?
2

Call to run macro when shett activated?

Call to run macro when shett activated?

(OP)
Lets say I have a Workbook with 2 Sheets in it, Sheet 1 and Sheet 2.  Is there a way I can make a macro (automatically) run every time the user selects/activates Sheet 2?  Also, if the file is opened and Sheet 2 is the active Sheet, I would like the macro to (automatically) run then too.

Thanks,
Ken

RE: Call to run macro when shett activated?

The Worksheet_Activate() event handler will do what you want.  Put in there whatever code you want to be run.  (This event handler can be found in the code window of the appropriate sheet object.)

HTH

RE: Call to run macro when shett activated?

Denial,

Can you give more detail for the VB-illiterates like me?  Where does Worksheet_Activate() go?  Is it part of the macro, or does it call the macro?  Thanks.

RE: Call to run macro when shett activated?

2
1. Go to Tools|Macro|Visual Basic Editor (or hit ALT-F11).
2. Open the Projects exploere (CTL-R)
3. Select the sheet whose events you're looking for
4. In the DropDown at the top left of the sheet code window Select Worksheet
5. In the DropDown top right select Activate
6. Put your code here:
Private Sub Worksheet_Activate()
' Your code
End Sub

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

RE: Call to run macro when shett activated?

(OP)
WOW!  That was so easy.  I can't believe I spent so many hours on this.
Thanks!
Ken

RE: Call to run macro when shett activated?

Can this be applied to everytime you check out and check in something from and to the vault?  

RE: Call to run macro when shett activated?

Not sure what you mean by the vault. Worksheet_Activate is fired each time the worksheet gets focus from within the app.

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

UK steam enthusiasts: www.essexsteam.co.uk

RE: Call to run macro when shett activated?

Sorry, we call our PDMWorks server the vault.  What I meant was, is there an event that gets triggered upon checking in or out from PDMWorks?  That way a macro would be automatically run whenever a part gets checked in or out.

RE: Call to run macro when shett activated?

Sorry again!  I found this port on a search and didnt realize it was specific to spreadsheets.  But if anyone works with SolidWorks and has an answer, please let me know.

RE: Call to run macro when shett activated?

You'll do better to ask this in Forum559

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting

UK steam enthusiasts: www.essexsteam.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources