Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginner wants to run userform 1

Status
Not open for further replies.

StarA

Programmer
Apr 20, 2003
1
US
Hi,
This is the first program I've every made in visual basic so be kind.
I've created a userform in excel by going straight to visual basic from sheet1 through 'Alt F11' and now the only way I can run the program is by going into visual then hitting f5. How can I cause the userform to run automatically from the excel document? Or better yet cause the form to always be displayed at the top of one of my excel sheets?
I know this must seem like a stupid question but I've searched and searched to no avail.
Thanks,
 
Hi,

What exactly does the form do and what purpose does it have? How it appears, can depend on what the form is to do for you.

For example, if the form asks the user a question or asks for some sort of input, then the form could appear if a certain cell is selected.. You can also add a command button to the sheet that calls the form..

Anyway, let us know some more info..

Cheers,

Renegade..

BULLET-PROOF DESiGNZ
renegade@tiscali.co.uk
 
Open up the Modules, add one. Type this:

[tt]Option Explicit

Sub Start()
Form1.Show
End Sub

[/tt]Or whatever the name of your userform is... Now put a button or something on your excel form... bring up the Forms Toolbar, select Button. Plonk the button down, right click on it, choose Assign A Macro. Choose the macro named Start. Click OK. When you click the button, your form will show.

If you want the form to run automatically when Excel starts, open up the code for This Workbook, use this:

[tt]Private Sub Workbook_Open()
Form1.Show
End Sub
[/tt]
 
Many thanks! This solved a problem that I just mentioned in another thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top