ComboBox Filling

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Found elsewhere on the web:

Rich (BB code):
Private Sub Workbook_Open()
Sheet1.Combobox1.List=Getobject("ListWorkbook.path & name.xlsx").sheets("sheet1").Range("B2:B6").Value
End Sub

The full path an name of the workbook that contains the list
The sheet name that the list resides upon
The range on that sheet the list sits in
 
Upvote 0
Perhaps:-

Code:
Sheets("Sheet1").ComboBox1.List = GetObject(ThisWorkbook.Path & "\Test.xlsm").Sheets("sheet1").Range("B2:B6").Value
 
Upvote 0
on Mac I had to amend it slightly, just incase you or anyone who stumbles by with the same question needs it to work on Mac:

Code:
Sheet1.DropDowns(1).List = GetObject("/Users/Cooper645/Desktop/list.xlsx").Sheets("sheet1").Range("B2:B6").Value
 
Upvote 0
Perhaps:-

Code:
Sheets("Sheet1").ComboBox1.List = GetObject(ThisWorkbook.Path & "\Test.xlsm").Sheets("sheet1").Range("B2:B6").Value

Dear Sir

I am using this code in vba to load the combobox2 with values in another workbook book1

Private Sub ComboBox2_Change()
Dim wb As Workbook
Dim ws As Worksheet
Dim wbsource As Worksheet
Dim i As Integer
Dim j As Integer
Dim rngSource As Range
On Error Resume Next
'ComboBox2.Clear
wb = Workbooks.Open("C:\users\MAC\New folder\Book1\ProductCode")
Sheets("CodeMaster").Select
Worksheets("Sheet1").Activate
Set rngSource = Range("B1:B" & Sheets("CodeMaster").Cells(Rows.Count, "B").End(xlUp).Row)
Sheet1.ComboBox2.Clear
j = 2
For i = 1 To rngSource.Rows.Count
Sheet1.ComboBox2.AddItem (rngSource.Item(j))
j = j + 1
Next i
End Sub

I it not showing any error, but values are not getting loaded
 
Upvote 0
Try something like this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG07Apr03
[COLOR="Navy"]Dim[/COLOR] Wb [COLOR="Navy"]As[/COLOR] Workbook, Rng [COLOR="Navy"]As[/COLOR] Range
'[COLOR="Green"][B]WB = Workbook to get Data from Including File Name[/B][/COLOR]
[COLOR="Navy"]Set[/COLOR] Wb = Workbooks.Open(ThisWorkbook.Path & "\test.xlsm")
[COLOR="Navy"]With[/COLOR] Wb.Sheets("Sheet1")
    [COLOR="Navy"]Set[/COLOR] Rng = .Range(.Range("B1"), .Range("B" & Rows.Count).End(xlUp))
[COLOR="Navy"]End[/COLOR] With

'[COLOR="Green"][B]Workbook with combobox:-[/B][/COLOR]
[COLOR="Navy"]With[/COLOR] Workbooks("MyWkBook.xlsm").Sheets("Sheet4").ComboBox1
    .Clear
    .List = Rng.Value
[COLOR="Navy"]End[/COLOR] With
Wb.Close SaveChanges:=False
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,217,385
Messages
6,136,277
Members
450,001
Latest member
KWeekley08

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