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: 51

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,772
Office Version
  1. 365
Platform
  1. Windows
What is the error message that you get?
 

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
684
Office Version
  1. 365
Platform
  1. Windows
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
 

bbworld

New Member
Joined
Jul 29, 2019
Messages
10
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: 157
  • Module 1.PNG
    Module 1.PNG
    181.7 KB · Views: 156

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
684
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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
 

bbworld

New Member
Joined
Jul 29, 2019
Messages
10
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?
 

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
684
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,772
Office Version
  1. 365
Platform
  1. Windows
What error do you get with your original code?
 

bbworld

New Member
Joined
Jul 29, 2019
Messages
10
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: 162
  • Module 1.PNG
    Module 1.PNG
    175.6 KB · Views: 163
  • Module 2.PNG
    Module 2.PNG
    104.4 KB · Views: 159

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,772
Office Version
  1. 365
Platform
  1. Windows
FYI the best way to get help, is to answer the questions that have been asked of you. ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,129,991
Messages
5,639,415
Members
417,088
Latest member
jonstr101

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