Linking Cells to ListBox - How?

  • Thread starter Thread starter William C. Smith
  • Start date Start date
W

William C. Smith

Is it possible to link a range of cells to a listbox: i.e. when code
executes a show method the list box displays the contents of the linked
cells.

Bill
 
William,

At design-time you can set the 'RowSource' property of the listbox in the
properites window of the listbox to a named range of the Workbook. Or you
can do the same at runtime using the listbox's RowSource property, eg.,

Form1.Listbox1.RowSource = "MyRange"

Or, define and name the range at runtime, eg.,

Range("A1:A10").Name = "MyRange"
Form1.Listbox1.RowSource = "MyRange"
Form1.Show

Or, if you pefer not to name the range (naming the range results in the
workbook containing that named range), you can just define the range and
fill the listbox item by item, eg.,

Dim cell As Range
For each cell in Range("A1:A10")
Form1.Listbox1.AddItem (cell.Value)
Next cell
Form1.Show

HTH,
Shockley
 
At design-time you can set the 'RowSource' property of the listbox in the

Thank you. I had been to the Properties Window, but how to use it is not
obvious. After your help I still had to experiment to find the right way to
insert a name in the value field. Help was no help.

Again Thank You.
 
Back
Top