Auto run Macro on Startup Conflict

Josh_Johnson

New Member
Joined
Mar 20, 2017
Messages
4
This is my first time posting on the forum, so I want to go ahead and thank you all for the support that you have given me so far.

I am very new to VBA & Macros, so if my question seems silly, I apologize. I have tried researching this, but I cannot find an answer.


Here is what I have: I am creating a workbook with numerous sheets on it that will be saved on a public drive. Whenever a user opens the workbook I want the "Table of Contents" worksheet to come up. I coded this like:


Private Sub Workbook Open()
Worksheets ("Table of Contents").Activate
End Sub


This works fine, but what I also want is for a Msg box to come up whenever they open the Workbook as well. I had this coded as:

Private Sub Workbook Open()
Msgbox ("Content")
End Sub

This gave me an error because of them having the same name, so i tried changing to

Private Sub Workbook Auto Open()
Msgbox ("Content")
End Sub

This still did not work.

I can make one or the other work, but never both. What do I need to do?

Thanks,

VBA NEWB
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Welcome to the Board!

Just place both sections of code in the same procedure, i.e.
Code:
[COLOR=#333333]Private Sub Workbook Open()[/COLOR]
[COLOR=#333333]    Worksheets ("Table of Contents").Activate
[/COLOR][COLOR=#333333]    Msgbox ("Content")[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
Note that you cannot change the name of event procedures. They MUST be named in a certain way for them to work, and you cannot have two procedures in the same module with the same name.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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