Hide workbook code

S

sunspot27

Can someone help?

I have a user form that i created in a spreadsheet to automatically
launch when the workbook is opened. Can anyone tell me what code i can
use to prevent the workbook from being displayed when i open it and
only display the user form? Also where i need to place this.

Also what code can i use to break from a loop or a case or jus end the
code compilation ?

Thanks
 
B

Bob Umlas

You can do this:
In the Workbook open event:

Private Sub Workbook_Open()
UserForm1.Show
End Sub
In the userform code:

Private Sub UserForm_Initialize()
Application.WindowState = xlNormal
Application.Left = -2000 'makes excel be off screen
End Sub

Private Sub CommandButton1_Click()
Application.Left = 0 'restores excel
Application.WindowState = xlMaximized
Unload Me
End Sub

To exit from a for/next loop:
Exit For
or
Go to some label after the Next

Don't think you can interrupt code compilation!
Esc key or Ctrl/Break could interrupt a loop as well.

HTH
Bob Umlas
Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top