autorun code when opening sheet (not workbook)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H

I have a code that I want to use... but automaticalled when one enters a sheet. How do i do this

For instanc

If i click on "sheet2
Sheet 2 opens u

I want it so that If i click on sheet2 (open sheet2
that a code of my choosing will automatically run for that sheet

Thanks
Steve Mutambo
 
Steve,

Use the Activate event of the worksheet. Right click on the sheet
tab and choose View Code. In the code module that opens up, use

Private Sub Worksheet_Activate()
' your code here
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


message
Hi

I have a code that I want to use... but automaticalled when one
enters a sheet. How do i do this?
 
Steve,

you need to put your code in the Activate event of the
worksheet. To do this from the VBE, double click on the
relevant sheet in the Project Explorer window,
select "Worksheet" from the first dropdown and "Activate"
from the second.

Insert the required code.

Cheers, Pete.

-----Original Message-----
Hi

I have a code that I want to use... but automaticalled
when one enters a sheet. How do i do this?
 

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