ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Combo Source from another file (https://www.excelbanter.com/excel-programming/369497-combo-source-another-file.html)

Steve

Combo Source from another file
 
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

Jim Cone

Combo Source from another file
 
Try...

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



"Steve"
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

Steve

Combo Source from another file
 
Outstanding!!! That did the trick. Thanks Jim

"Jim Cone" wrote:

Try...

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



"Steve"
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



All times are GMT +1. The time now is 09:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com