Multiple lists in a single List Box

This example demonstrates how to create a ListBox in which the contents change depending on the user's selection from a group of OptionButtons.

Figure 14-11 shows the sample UserForm. The ListBox gets its items from a worksheet range. The procedures that handle the Click event for the optionButton controls simply set the ListBox's RowSource property to a different range. One of these procedures follows:

H

Ç

F^t-fMdr,

Pçrç1

Quriif

i IriRas rtarr.o

Liiert alii

Teïtaw

1

Mi

1

Api «1

TfYfl4* MtU*

ÎW" Hut

IÎ f^.

.pj.'jry

1

Tar«»

__- 1—1

4

JW*

irdip>

r rjisï

■hnr

1

Jvtf

: j

HijfirTT

(»nrtflr

J*. J

il

IS

1ft

II 1 r III Slr^'

4L j

513

*

Figure 14-11: The contents of this ListBox depend on the OptionButton selected.

Figure 14-11: The contents of this ListBox depend on the OptionButton selected.

Private Sub obMonths_Click()

ListBox1.RowSource = "Sheet1!Months" End Sub

Clicking the OptionButton named obMonths changes the RowSource property of the ListBox to use a range named Months on Sheet1 .

CD-ROM

This example, named listbox multiple lists .xlsm , is available on the companion CD-ROM.

0 0

Post a comment