ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Making a Dynamic List in Listbox (https://www.excelbanter.com/excel-programming/285547-making-dynamic-list-listbox.html)

MikeM[_4_]

Making a Dynamic List in Listbox
 
Is it possible to change the length of a list using
listbox? I have 2 listboxes on a worksheet, the first
containing a (fixed) list of the 50 states (A1:A50). On
choosing a state I copy a list of county names into column
B, to which the second listbox is set, using the
ListFillRange property. Is thre some way to change the
ListFillRange to become the right length when the state
changes?

MikeM[_4_]

Making a Dynamic List in Listbox
 
Never mind, I found outhow to do it -- I thought the
argument for ListFillRange was a range, but it's a string,
"B1:Bxx"

-----Original Message-----
Is it possible to change the length of a list using
listbox? I have 2 listboxes on a worksheet, the first
containing a (fixed) list of the 50 states (A1:A50). On
choosing a state I copy a list of county names into column
B, to which the second listbox is set, using the
ListFillRange property. Is thre some way to change the
ListFillRange to become the right length when the state
changes?
.


Tom Ogilvy

Making a Dynamic List in Listbox
 
In the click event of the first listbox, populate your range, then set the
listfillrange property of the second listbox

With worksheets("Data")
set rng = .Range(.cells(1,2),.cells(1,2).End(xldown))
End With
Listbox2.ListFillRange = rng.address(external:=True)

--
Regards,
Tom Ogilvy

"MikeM" wrote in message
...
Is it possible to change the length of a list using
listbox? I have 2 listboxes on a worksheet, the first
containing a (fixed) list of the 50 states (A1:A50). On
choosing a state I copy a list of county names into column
B, to which the second listbox is set, using the
ListFillRange property. Is thre some way to change the
ListFillRange to become the right length when the state
changes?





All times are GMT +1. The time now is 08:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com