Combo Source from another file

G

Guest

I am trying to use data from a separate file to populate a ComboBox but am
having trouble. the code is crashing on the follwing statement;
"wb1.Sheets("GUI").ComboBox1.ListFillRange =
wb2.Sheets("Info").Range("A1:A4")". Could someone point me in the right
direction please?

Dim Sht As Worksheet
Dim FolderName As String
Dim wb1, wb2 As Workbook

FolderName = "C:\info.xls"

Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Open(FolderName)

For Each Sht In wb2.Worksheets
If Sht.Name = "Info" Then
wb1.Sheets("GUI").ComboBox1.ListFillRange =
wb2.Sheets("Info").Range("A1:A4")
wb2.Close 'False
Exit For
End If
Next Sht
 
J

Jim Cone

Try...

"wb1.Sheets("GUI").ComboBox1.ListFillRange =
wb2.Sheets("Info").Range("A1:A4")".Address(External:=True)
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Steve" <[email protected]>
wrote in message
I am trying to use data from a separate file to populate a ComboBox but am
having trouble. the code is crashing on the follwing statement;
"wb1.Sheets("GUI").ComboBox1.ListFillRange =
wb2.Sheets("Info").Range("A1:A4")". Could someone point me in the right
direction please?

Dim Sht As Worksheet
Dim FolderName As String
Dim wb1, wb2 As Workbook
FolderName = "C:\info.xls"
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Open(FolderName)
For Each Sht In wb2.Worksheets
If Sht.Name = "Info" Then
wb1.Sheets("GUI").ComboBox1.ListFillRange =
wb2.Sheets("Info").Range("A1:A4")
wb2.Close 'False
Exit For
End If
Next Sht
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top