Excel 97 VBA: Binding a combo to a named range

  • Thread starter Thread starter David
  • Start date Start date
D

David

In the past when using combo boxes I've added items to
them using the add method.

I'd like to reference a named range from a separate stand
alone spreadsheet, so that I can provide a combobox that
has values that can be maintained separately.

I can't work out how one binds a combo in this way? Can
anyone help?


Many thanks


David
 
Hi David:

Just right-click on the ComboBox to access its properties, and then set the
RowSource (or ListFillRange) property to the string rpresenting the source
range address. Or, in code:

ComboBox1.RowSource = "Sheet2!A1:A10"

Regards,

Vasant.
 
Thanks very much Vasant.

I can get that to work but I was trying to reference a
named range. This is what I've got but it doesn't work:
ComboBox1.RowSource = Range("test")

"test" is the name of a range in the current book. Ideally
I would like to reference a range in a separate standalone
book.
 
David,

Need to use a String
ComboBox1.RowSource = Range("test").Address

May need to qualify the worksheet
ComboBox1.RowSource = Sheets("Sheet1").Range("test").Address
 
ComboBox1.RowSource = Sheets("Sheet1").Range("test").Address(external:=true)

Will include the worksheet name in the string. (along with the workbook name,
too.)
 
Thanks very much guys


Dave Peterson said:
ComboBox1.RowSource = Sheets("Sheet1").Range("test").Address(external:=true)

Will include the worksheet name in the string. (along with the workbook name,
too.)
 
Back
Top