Sub Show Form () Error

bbworld

New Member
Joined
Jul 29, 2019
Messages
10
Hello,

I am a newbie with VBA and have reviewed the previous articles on the Sub Show Form () error I am getting in the attached.

I have followed a learning video and rechecked my content twice yet the same error is presenting.

The workbook is attached and the code in particular that is causing grief is;

Sub Showform()

frmForm.Show

End Sub

I have checked the declaration on the Sub and it matches the code.

Seriously at a loss.
 

Attachments

  • Sub Error.PNG
    Sub Error.PNG
    5.4 KB · Views: 267

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What is the error message that you get?
 
Upvote 0
This code opens up a UserForm in the middle of the application everytime. If this doesn't work, then you either have the code in the wrong location or the UserForm is named something different. This code should not be in any Worksheet modules.
VBA Code:
Sub showForm()
    With frmForm
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
        .Show
    End With
End Sub
 
Upvote 0
Thanks for the prompt help.

I have ran the newer code from @VBE313 and attached are the errors/issues/my newbie oversights.
 

Attachments

  • Run-Time error.PNG
    Run-Time error.PNG
    131.4 KB · Views: 787
  • Module 1.PNG
    Module 1.PNG
    181.7 KB · Views: 784
Upvote 0
those codes should be in the UserForm module, take all that code and cut it, paste it in the UserForm module, double click a gray area in the UserForm to activate the UserForm module and paste the code in there
 
Upvote 0
those codes should be in the UserForm module, take all that code and cut it, paste it in the UserForm module, double click a gray area in the UserForm to activate the UserForm module and paste the code in there
Sorry, just to confirm, the code you gave me is all that should be moved?
 
Upvote 0
any code that should be used in the UserForm needs to be in the UserForm module, the code I sent you is meant to be outside of the UserForm so you can activate it.
 
Upvote 0
What error do you get with your original code?
 
Upvote 0
Cheers for your support.

This is what I have built, again I was following a lesson from 2019 so maybe this is not best practice.

Form
Module 1
Module 2

Happy to hear back from you when you have a moment. (I know another newbie, but I guess this post will help new learners in the future :) )
 

Attachments

  • frmform.PNG
    frmform.PNG
    167.9 KB · Views: 779
  • Module 1.PNG
    Module 1.PNG
    175.6 KB · Views: 780
  • Module 2.PNG
    Module 2.PNG
    104.4 KB · Views: 771
Upvote 0
FYI the best way to get help, is to answer the questions that have been asked of you. ;)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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