Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Type Mismatch: Unable to create Listbox in UserForm

Status
Not open for further replies.

Fwit

Electrical
May 11, 2003
2
Pulling my hair out here. It's a while since I did any VB and of course stuff has changed but.... I create a userform and add a listbox. A line of code in the initialize event adds one item for test purposes. I then create a module that loads and shows the form. Save the project, close it and reopen it and as soon as I run the macro I get Type Mismatch. This error also occurs sometimes when adding the listbox to the form in the first place. Buttons and labels are Ok but Listboxes, textboxes, combos etc all cause Type Mismatch. Any advice much appreciated.
 
Replies continue below

Recommended for you

Have you declared the variables properly?
 
That's what I thought so I have put my original project with loads of variables aside while I try and figure out what is going on. So I just have a Userform with a Label and Command button and the code for this is
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub

Private Sub UserForm_Initialize()
Label1.Caption = "Hooray"
End Sub

And a Module linked to a button on a worksheet to show the userform, the code for which is

Sub showform()
Load UserForm1
UserForm1.Show
End Sub

This works fine but as soon as I try and drag another control such as a listbox or textbox onto the Userform from the toolbox I get a Type Mismatch error even before attempting to add any code or run it. I must be missing something obvious.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor