Macro - When opening file return to tab main_Menu

Johnny Thunder

Well-known Member
Joined
Apr 9, 2010
Messages
693
Office Version
  1. 2016
Platform
  1. MacOS
Hello,

I am trying to enter a macro for when my excel fie is opened it will go to a specific tab ("Main_Menu") always.

This is so that when my shared filed gets saved in another tab the next user that opens it will go directly to the Main_menu tab.

Thanks in advance for your help!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Put this in your ThisWorkbook module:

Code:
Private Sub Workbook_Open()
Worksheets("Main_Menu").Activate
End Sub
 
Upvote 0
I pasted it into the "This Workbook" and when I save and close the file to try I get the Debugger? It highlights this "Worksheets("Main_Menu").Activate" ??? Did I do something wrong?
 
Upvote 0
Hi,

Are you sure you have a worksheet called "Main_Menu" which is visible?

kind regards,
Erik

EDIT: apparently there is no error even when it is not visible (tested XL2003 and XL2007)
 
Last edited:
Upvote 0
Yes, i do have a Sheet named "Main_Menu" Maybe I pasted it in wrong? Or in the wrong place?

I went to the object view under VBA Projects>This Workbook> and then entered the macro on the page and saved it?
 
Upvote 0
Sorry for the confusion. I entered the macro in, then save and close the workbook;it closes fine. then, when I go to test the macro and open the work book, I enable macro (Security question) I get the debugger, I click debug and I see the line highlighted?
 
Upvote 0
Generally that is indicative of trying to call something by index that is not available (like calling a worksheet that isn't there). Maybe we could try a test? In the workbook, rename your Main_menu to simply Main and update the code. Save, close and reopen. Let me know how that goes.

-Justin
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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