ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic range not resized for RowSource usage (https://www.excelbanter.com/excel-programming/306369-dynamic-range-not-resized-rowsource-usage.html)

Tim Zych[_8_]

Dynamic range not resized for RowSource usage
 
I've defined a range name "rng":

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$6553 6),1)

and then used that as the rowsource for a listbox in a userform.

Problem is, when I add a new value to the list, the range is not resized
until I close/reopen the form.

Anybody know a workaround?

Thanks.




Vasant Nanavati

Dynamic range not resized for RowSource usage
 
Hi Tim:

I'm assuming you are using a modeless UserForm. This worked for me:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then UserForm1.ListBox1.RowSource = "rng"
End Sub

--

Vasant

"Tim Zych" wrote in message
...
I've defined a range name "rng":

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$6553 6),1)

and then used that as the rowsource for a listbox in a userform.

Problem is, when I add a new value to the list, the range is not resized
until I close/reopen the form.

Anybody know a workaround?

Thanks.






Tom Ogilvy

Dynamic range not resized for RowSource usage
 
rowsource doesn't work very well with defined names - at least not very
dynamically. Reassign the rowsource should make it use the latest value.

--
Regards,
Tom Ogilvy

"Tim Zych" wrote in message
...
I've defined a range name "rng":

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$6553 6),1)

and then used that as the rowsource for a listbox in a userform.

Problem is, when I add a new value to the list, the range is not resized
until I close/reopen the form.

Anybody know a workaround?

Thanks.






Tim Zych[_8_]

Dynamic range not resized for RowSource usage
 
Vasant, Tom:
I thought I tried that and it didn't work. Guess not. Programmatically
resetting it seems to fix it.
Thanks

"Tom Ogilvy" wrote in message
...
rowsource doesn't work very well with defined names - at least not very
dynamically. Reassign the rowsource should make it use the latest value.

--
Regards,
Tom Ogilvy

"Tim Zych" wrote in message
...
I've defined a range name "rng":

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$6553 6),1)

and then used that as the rowsource for a listbox in a userform.

Problem is, when I add a new value to the list, the range is not resized
until I close/reopen the form.

Anybody know a workaround?

Thanks.









All times are GMT +1. The time now is 05:09 PM.

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