ComboBox Populate

wtom0412

Board Regular
Joined
Jan 3, 2015
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am using the following code to populate two ComboBoxs in my Userform (called WSSearch).

Code:
Private Sub UserForm_Initialize()

    Me.ComboBox1.List = Sheets("Wholesale Members").Range("A2", Range("A" & Rows.Count).End(xlUp)).Value
    Me.ComboBox2.List = Sheets("Wholesale Members").Range("B2", Range("B" & Rows.Count).End(xlUp)).Value

End Sub

When I run this Userform, I get a "Run-time error '1004': Application-defined or object-defined error"

I am stuck, can anyone please help?

Cheers, WT
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You need to put "Sheets("Wholesale Members")." in front of each "Range", and it's better to use "With - End With"

Code:
Private Sub UserForm_Initialize()
With Sheets("Wholesale Members")
    Me.ComboBox1.List = .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Value
    Me.ComboBox2.List = .Range("B2", .Range("B" & Rows.Count).End(xlUp)).Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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