Dynamic range not resized for RowSource usage

  • Thread starter Thread starter Tim Zych
  • Start date Start date
T

Tim Zych

I've defined a range name "rng":

=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$65536),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.
 
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
 
rowsource doesn't work very well with defined names - at least not very
dynamically. Reassign the rowsource should make it use the latest value.
 
Vasant, Tom:
I thought I tried that and it didn't work. Guess not. Programmatically
resetting it seems to fix it.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top