klnp_mysore
Board Regular
- Joined
- Mar 2, 2011
- Messages
- 64
Dear Sir,
How to fill combobox with values from another workbook in VBA
Regards
How to fill combobox with values from another workbook in VBA
Regards
Private Sub Workbook_Open()
Sheet1.Combobox1.List=Getobject("ListWorkbook.path & name.xlsx").sheets("sheet1").Range("B2:B6").Value
End Sub
Sheet1.DropDowns(1).List = GetObject("/Users/Cooper645/Desktop/list.xlsx").Sheets("sheet1").Range("B2:B6").Value
Perhaps:-
Code:Sheets("Sheet1").ComboBox1.List = GetObject(ThisWorkbook.Path & "\Test.xlsm").Sheets("sheet1").Range("B2:B6").Value
[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