0

Hi "im kind of new with excel VBA. I'm trying to do something simple as creating a USERFORM1 in VBA and showing it when workbook opens. I've looked it up online but for some reason something is not working.

I open excel, go to developer, create a userform1, add some stuff to it.

I open code for THISWORKBOOK and under Open procedure I type

Private Sub Workbook_Open()
UserForm1.Show

End Sub

Then I save it as Macro Enabled and when i open it, nothing happens. What is going on? I know this is a silly question but am i doing something wrong?

5
  • Where did you place that code? "Workbook_Open procedure MUST reside in the private module of the Workbook Object (ThisWorkbook)" Commented Sep 21, 2016 at 19:06
  • @BruceWayne I right click on ThisWorkbook open the module and type the code there. I select WORKBOOK from the drop down and same with OPEN Commented Sep 21, 2016 at 19:06
  • 1
    Looks correct to me - check to make it runs manually by creating a test sub that does Userform1.Show - then run it using F5. Also - make sure it's actually in the file you saved - if you open the file (.xlsm extension) is it actually in your code? You have to open the file that ends in .xlsm Commented Sep 21, 2016 at 19:13
  • In the Immediate Window, (Press CTRL+G in the VB Editor), type UserForm1.Show. It should pop up for you. If it doesn't let us know. Commented Sep 21, 2016 at 19:13
  • 2
    @i didn't have macros enabled in Trust Center. All set thanks forlks! Commented Sep 21, 2016 at 19:18

1 Answer 1

0

In trust center I didn't have macros enabled. I did that and everything seems to work perfectly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.