Using a button to select a macro to go to a sheet

aldino

New Member
Joined
Nov 20, 2005
Messages
7
Hi

Basically i need to have 2 buttons on a contents page, that will go to sheet 2, and 3 when clicked.

I have tried assigning

Sub Sheet2()
Sheets("Sheet2").Select
End Sub

to a button, but then when i press the button always an error comes up!

does the first line have to be Sub Button1_Click()?

Im not sure how to save it in VBA

What exactly should the code be?

Thanks.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
the name depends on your button's name (in this case "Button1" I suppose)

then it should start with: Sub Button1_Click()
 
Upvote 0
What sort of button are you using ?

There are two main types,

A forms button You can right click these & assign a macro from a normal module

A controls button - you need to code this in the relevant sheet code module
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,939
Latest member
Leon Leenders

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