How to add a return to page into a before close macro

country101

Board Regular
Joined
May 31, 2012
Messages
61
I have a macro already made(thanks to people on here) protect all the worksheets upon leaving. One thing I have noticed as I go into these workbooks is it opens on whatever page you left or saved on. I would like it to open up to the first sheet, which is my master. Could anybody edit the macro so that it always opens to this sheet?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Select Case ws.Name
Case "Delta Crew"
ws.Protect "delta"
Case "Dumas"
ws.Protect "supervisor"
Case "Fox"
ws.Protect "supervisor"
Case "Freeman"
ws.Protect "supervisor"
Case "Karnes"
ws.Protect "supervisor"
Case "McGee"
ws.Protect "supervisor"
Case "Morris"
ws.Protect "supervisor"
Case "Spanke"
ws.Protect "supervisor"
Case "Data"
With ws
.Protect "delta"
.Visible = xlVeryHidden
End With<o:p></o:p>

End Select
Next ws
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Put this in the same module as your _beforeClose code. above it will be fine:

Code:
Private Sub Workbook_Open()
Me.Sheets("Name_of_your_master _here").Activate
End Sub

Obviously, substitute the name of your "Master" sheet in between the brackets, and keep the quotation marks as well
 
Upvote 0
Sorry it has taken so long to get back. Thanks for the help. I have not tried this out yet. Will this take it back to the master page for anybody, or just me?
 
Upvote 0
It'll work for everyone, but it's important that you put it in the right place - so paste it in the same module as the code you've already posted. Above or below it will be fine.

This code will run each time anyone opens the workbook, and will open on your master sheet - as long as you substitute "Name_of_your_master _here" with the actual name of your master sheet.
 
Upvote 0
Pleasure. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,203,242
Messages
6,054,354
Members
444,718
Latest member
r0nster

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
Back
Top