VBA - UserForm1.Show

george hart

Board Regular
Joined
Dec 4, 2008
Messages
241
Hi

When I run this I get the de-bug. Not sure why though. I use this in other macros and it appears to work fine????? ?Any ideas

In short I need a button that when clicked opens UserForm1

Sub Button35_Click()
UserForm1.Show
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Check the name of your userform: Your code should work if your userform is named UserForm1.

Most likely it's needless to say but make sure you have your macros enabled + you are really clicking "Button35" when trying to fire the macro.
 
Upvote 0
There is probably an error in the Initialize event (or Activate event) code in your userform. Press f8 to step into the form code, then keep pressing f8 until you reach the actual error line.
 
Upvote 0
Ah, after hitting F8, it falls over here - in bold...

Dim ListItems As Variant, i As Integer
'Dim SourceWB As Workbook
With Me.ComboBox1
.Clear
' open the source workbook as ReadOnly
Set SourceWB = Worksheets("Tracker").Range("C3:C3000").Value
ListItems = SourceWB

ListItems = Application.WorksheetFunction.Transpose(ListItems)
' convert values to a vertical array
For i = 1 To UBound(ListItems)
.AddItem ListItems(i) ' populate the listbox
Next i
ComboBox1.ListIndex = 1 ' no items selected, set to 0 to select the first item
End With

End Sub
 
Upvote 0
Can you explain what that line of code is trying to do?
 
Upvote 0
Remove the 'Set' from the start of that line. (Of course, your variable name makes no sense as it's not a Workbook, but never mind ;))
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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