Combo box source from other workbook

S

Steven

I have a file "File01.xls" with a range "List". This file has a UserForm1
with a ComboBox where the RowSource is range "List". The UserForm is
accessible from any open file. How do I set the RowSource to the "List"
range so it works regardless of the current active workbook. I get an error
when the current active file is not "File01.xls".

Thank you,

Steven
 
T

Tim Zych

Do you want to use the active workbook's List range name or confine it to
one workbook?

If one workbook:

Dim rowSrc As String
rowSrc =
Workbooks("File01.xls").Names("List").RefersToRange.Address(External:=True)
UserForm1.ComboBox1.RowSource = rowSrc ' Or Me.Combobox1 if the code is in
the userform

or if the active workbook:

Dim rowSrc As String
rowSrc = ActiveWorkbook.Names("List").RefersToRange.Address(External:=True)
UserForm1.ComboBox1.RowSource = rowSrc
 
Top