Dowlers
Dowlers

Reputation: 1494

Use a named range in an excel worksheet to propagate a listbox

So I have a number of namedRanges in an excel worksheet. I would like to use these to fill in comboboxes on a user form in the same WorkBook.

I have tried:

cboMember.DataSource = Globals.Sheet1.MemberRange.Value

No error is given but the combo is blank. Does anybody have any ideas?

I'm trying to use VSTO for VS 2008 on an excel 2003 work book.

Upvotes: 2

Views: 1009

Answers (2)

ccampj
ccampj

Reputation: 725

cboMember.RowSource = "NamedRange"

You don't set it to an object. Set it to a string. Excel figures out the rest.

Upvotes: 3

Rory
Rory

Reputation: 41817

This is a bit of a guess, but I believe in VBA you can do something like just Range("MyRangeName") to get the named range, so you could try the equivalent of that.

Some ranges in Excel are local to a sheet, some are global to the workbook. If they're local to a sheet then you'll need to prefix with sheet name, e.g. Range("Sheet1!MyRangeName").

Upvotes: 3

Related Questions