Increase the list fill range with vba

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
How do I increase the list fill range so that when I add items to my list, a combo box that has a list of the items in it is updated automatically. The Listfillrange property of my combo box is YPNames!$A$2:$A48 but I want it to be A2 to the bottom of the list on YPNames.
 
I can't see where it is the same object twice as I was only running that procedure.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I think I have found out how you might be able to do it.

If you make the list of names a named range then put that name in the listfillrange, it appears to work. Only thing now is to when new names are added to the list, they will have to be added to the named range. Do you know how to do that?
 
Upvote 0
I would have thought a named range woul be the way to go....you could code the new name to be added to the namefrange...then the list will update witj it
 
Upvote 0
I am trying to get it to select all the names entered in column A from A2. What is wrong with my code as it only selects the first name and the heading when there are 8? The heading is in A1.

VBA Code:
Sub aIncreaseNamedRange()

    With ActiveWorkbook.Names("myRange")
        .Name = "myRange"
        .RefersToR1C1 = "=YPNames!R2C1:R" & Range("A1").End(xlUp).Row & "C1"
        .Comment = ""
    End With
    Application.Goto Reference:="myRange"
End Sub
 
Upvote 0
you can't combine R1C1 with normal range references
So, either R1C1 or range("A" ........
 
Upvote 0
I even tried this code and it didn't work.

VBA Code:
Sub AddNameList()

Dim R As Range
Set R = Range("myRange")
R.Name.RefersTo = YP.Range("A2:A" & Range("A:A").End(xlUp).Row)

End Sub
 
Upvote 0
I think I want to steer away from the r1c1 references as I find them confusing.
 
Upvote 0
But as I mentioned, if you add a new name via D5 on the Tracker sheet, it updates the name in the list AND the NamedRange
 
Upvote 0
Make your named range dynamic for starters

The have the list fill refer to the Named Range rather than cell references
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top