auto open a particular worksheet when workbook opened

racheljane

New Member
Joined
Jul 31, 2007
Messages
9
Hi,
Can anyone tell me the vba code to automatically open sheet one when a workbook is opened? At the moment it opens on the page on which the workbook was last saved.
Thanks
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

dave3009

Well-known Member
Joined
Jun 23, 2006
Messages
7,128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
Hi There

Welcome to the board

Code:
Private Sub Workbook_Open()
Sheet1.Activate
End Sub

Ought to do it.

KR


Dave
 
Upvote 0

racheljane

New Member
Joined
Jul 31, 2007
Messages
9
thanks but it still opens up on the last saved page - is there something else I need to do? I'm quite new to vba. I've just saved this code in a module called auto_open. All the other macros I've recorded need a button to be pressed to activate them. ????
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
I've just saved this code in a module called auto_open.
That's the problem.

In the Visual Basic window, double click on "This Workbook" and paste the code there.

If that doesn't work, try changing the middle line to
Sheets("Sheet1").Activate
 
Upvote 0

racheljane

New Member
Joined
Jul 31, 2007
Messages
9
Sorry to be a pain - it still doesn't work??? If I double click in the vba window on 'this workbook', it just opens all the modules that I have.
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hi RachelJane,

At the top of excel where you have a command menu File Edit etc you will see a little excel icon in the top left next to 'File'

Right click this and choose view code.

Paste the code in there!

Also another thought...Is your sheet called Sheet1?

If not replace sheet1 with your sheet name:

Code:
Private Sub Workbook_Open() 
Sheets("Mysheetnamehere").Activate
End Sub
 
Upvote 0

racheljane

New Member
Joined
Jul 31, 2007
Messages
9
HI AdamC

It doesn't give me the option view code, only save or import file. Thanks for your patience!
Rachel
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hi Rachel.

Thats because you are right clicking on the visual basic editor commandbars. :biggrin:

Return to excel so your sheet is visible then repeat as above.

Let me know if this helps
 
Upvote 0

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Rachel,

Your very welcome, no need to apologise, if it wasnt for this forum id also be DIM! :biggrin:
 
Upvote 0

Forum statistics

Threads
1,191,586
Messages
5,987,502
Members
440,098
Latest member
MickyMouse123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top