Quick ?Macro short cut

cblackst

New Member
Joined
Jan 6, 2005
Messages
39
Hello All.

Is there a way I can create a macro that when a button is push the vba form will pop up on sheet1..?

Thank You.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

gsouza

New Member
Joined
Jul 30, 2004
Messages
40
This should work for you>
sub shovba()
Application.VBE.MainWindow.Visible = True
end sub
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
If you mean launching a UserForm, then using a button drawn on the sheet from the Control Toolbox:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
    UserForm1.Show
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

Smitty
 

cblackst

New Member
Joined
Jan 6, 2005
Messages
39

ADVERTISEMENT

I'm getting a error that VBE has failed, should this be my form name. which is UserForm1

Thanks
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
What's the exact error message?

If your form is really called "UserForm1" then the code above will work. Note that the code and the form name need to match exactly.

Can you post what you have?

Smitty
 

cblackst

New Member
Joined
Jan 6, 2005
Messages
39

ADVERTISEMENT

Thank You .

This worked perfect..

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
 

cblackst

New Member
Joined
Jan 6, 2005
Messages
39
Hello again..

ok, I'm still on the same program.. Is there away I can use another to print the form.

Thanks again
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Sure:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> CommandButton2_Click()
    UserForm1.PrintForm
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Smitty
 

Forum statistics

Threads
1,147,508
Messages
5,741,568
Members
423,667
Latest member
Kai_357

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
Top