From form to sheet with options button

magic

New Member
Joined
May 18, 2004
Messages
10
Hi guys

I have sheet A where you click a pic button and a form will appear (vbasic form) on this i have 4 option buttons and a command button. Is it poss to be able to click on one of the options buttons then click the command button and this will then take to the sheet you pick on the form
So
option box 1 is sheet 112
option box 2 is sheet 113 and so on

Thank you
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
There a couple of ways to achieve this.
Here's an example of the one you asked for:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
<SPAN style="color:#00007F">If</SPAN> OptionButton1 <SPAN style="color:#00007F">Then</SPAN>
    Sheets("Sheet 112").Select
<SPAN style="color:#00007F">ElseIf</SPAN> OptionButton2 <SPAN style="color:#00007F">Then</SPAN>
    Sheets("Sheet 113").Select
<SPAN style="color:#00007F">ElseIf</SPAN> OptionButton3 <SPAN style="color:#00007F">Then</SPAN>
    Sheets("Sheet 114").Select
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


However, you may not need the commandButton for this at all (depending on what all you're doing I guess).
You can simply assign the code to each of the optionbuttons themselves. (ie.)

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> OptionButton1_Click()
Sheets("Sheet 112").Select
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> OptionButton2_Click()
Sheets("Sheet 113").Select
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> OptionButton3_Click()
Sheets("Sheet 114").Select
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

One of these should be what you need.

Hope it helps,
Dan
 
Upvote 0

Forum statistics

Threads
1,215,018
Messages
6,122,703
Members
449,093
Latest member
Mnur

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