Open form with condition

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi anyone,

How could I write a macro code that on click would open the user form1, place the text in cell M10 on textbox1 and check the optionbutton1 and would click the button Next on load.

Is there a way I could place the code in standard module instead of the form module?

I hope I have made my question clear.

Thanks in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Well you could have all the code in a module, but populating the textbox, checking the optionbutton etc would probably be best kept in the userform module.

To open the form on the click of a button just add one to a worksheet.

Then either double click it or select it, right click and select Assign macro...

If you double clicked you should then see something like this.
Code:
Option Explicit
 
Private Sub CommandButton1_Click()
 
End Sub
If you used Assign macro the Macro dialog will appear.

Click New on that and you'll see something like this.
Code:
Option Explicit
 
Sub Button1_Click()
 
End Sub
Whichever you see just add this code to show the userform.
Code:
UserForm1.Show
Change UserForm1 to the name of your form.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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