Auto run macro on individual worksheet open

  • Thread starter Thread starter mr_teacher
  • Start date Start date
M

mr_teacher

Hi all

Apologies if this is elsewhere - had a look through but couldn't fin
an answer but I am a newbie so please bear with me!:)

I am attempting to automatically run a Macro in Excel when i open
worksheet but can't find a way to do this. I know I can have one set t
run when the whole workbook opens, but I need to have a different macr
running when different worksheets open and each time that an individua
worksheet is opened without closing down the whole workbook - basicall
to return to cell A1 on open (but it may not always be A it needs to g
to if that sheet is using a VLOOKUP and has numbers in the column)

Thanks for any help / advice you can offe
 
Right click the tab of the worksheet you want the macro to auto-run on
open. Choose "View Code"

VBA will open. At the top you should see "(General)" and
"(Declarations)" Click on "(General)" and choose "Worksheet".

"(Declarations)" will change to "SelectionChange". Click on
"SelectionChange" and choose "Activate".

You can then delete the following text:
"Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub"

Any code you put between: "Private Sub Worksheet_Activate()" and "End
Sub" will run when this particular worksheet is Activated.

Hope that helps.
-Ikaabod
 
Thank you so much for the reply!!!

I have been trying to work out a way to do that for weeks - and have
trawled through page after page of help stuff trying to find it!

Thta will make life so much easier now with the programme!!

Thanks again!

Carl
 

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