Activate Certain Sheet When Open a Workbook

qiqinuinaifen128

Board Regular
Joined
Dec 26, 2008
Messages
65
Dear Pros,

I have a question regarding the Excel VBA.
I have a workbook which has about 50 sheet. Is it possible to make the wookbook always activate sheet1 when the wookbook was open?

I know there is a private sub sth like below
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sub

But can anyone show me step by step how to do it. I am a beginner. I only know create macro and assign macro. So i don't know where to start although i find this code in internet.

I would appreciate if anyone can help me.
Thank you in advance and hope to hear from you soon.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Right click the Excel logo just to the left of File on the menu bar, select View Code and paste in

Code:
Private Sub Workbook_Open()
Sheets("Sheet1").Select
End Sub

Then save, close and re-open the workbook to see the effect.
 
Upvote 0

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Yeah, '07 has a much different interface. In '07 you can still hit ALT+F11 to open the VBE, then open the ThisWorkbook module. You can put Workbook level events, like Open, there (that's where Peter's code should go).

HTH,
 
Upvote 0

qiqinuinaifen128

Board Regular
Joined
Dec 26, 2008
Messages
65
ADVERTISEMENT
Hi,

Sorry to ask you stupic question. I am a beginner, can you guide me step by step. After i press ALT F11 and i see a window of VBA, the right site i can see the properties window, and i can see all my worksheet and my micro (Module), how should i go?
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
You should see something like this:

vbe.jpg


Double click on ThisWorkbook and paste in the code.
 
Upvote 0

Forum statistics

Threads
1,196,022
Messages
6,012,907
Members
441,740
Latest member
Latrs

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