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 tried that link you sent but it didn't seem to work. The named range refers to =OFFSET(Tracker!$A$2,0,0,COUNTA(Tracker!$A:$A),1)
but that doesn't do anything.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Did for me !!
I added 3 names via the Add Young Person button
When I clicked on the dropdown arrow for the ComboBox the names were there !
 
Upvote 0
I deleted all the names from the list and tried to add a name. All that was left in the list is the header in A1. The file gets created with the name that is entered but I get an error "Could not set the list property. Invalid property array index." If I press debug, this line is highlighted
VBA Code:
Tracker.lboYP.List = YP.Range("A2:A" & Lastrow).Value

in this procedure
Sub PopLB(TrackerWB As Workbook)
Dim Lastrow As Long
TrackerWB.Activate
Lastrow = YP.Cells(Rows.Count, "A").End(xlUp).Row
Tracker.lboYP.List = YP.Range("A2:A" & Lastrow).Value
End Sub
 
Upvote 0
So maybe you need to modify the code
VBA Code:
Sub PopLB(TrackerWB As Workbook)
Dim Lastrow As Long
TrackerWB.Activate
Lastrow = YP.Cells(Rows.Count, "A").End(xlUp).Row
If Lastrow=1 then Lastrow=Lastrow+1
Tracker.lboYP.List = YP.Range("A2:A" & Lastrow).Value
End Sub
But do you need that code if the list automatically updates ???
OR even...
VBA Code:
Sub PopLB(TrackerWB As Workbook)
Dim Lastrow As Long
TrackerWB.Activate
Lastrow = YP.Cells(Rows.Count, "A").End(xlUp).Row
If Lastrow=1 
MsgBox "There are no names on the list"
exit sub
end if
Tracker.lboYP.List = YP.Range("A2:A" & Lastrow).Value
End Sub
 
Upvote 0
I get permission denied with the last line highlighted.
 
Upvote 0
But why do you need that code ??
The list is updated when you add a new person ??
 
Upvote 0
If I comment out the PopLB code, the combo box and list box do not get updated. The list of names in the sheet YPNames is being updated each time I execute the code but the new names are not added to the list. 2 of the initial names I entered have been added but no new names have been added for a while. In the name manager, tblYPNames has a {...} in the value but if I click edit and put the cursor in the refers to field, the entire list of names is selected, including the new names that have been added. Although, the selection goes to one row below the last item in the list.
 
Upvote 0
Not sure why this happened Michael, I deleted all the names and tried to add in one at a time and it is working just as you described it to be. I will just get my boss to manually add the names in as that seems to work. Thanks for your help.
 
Upvote 0
Thanks Michael but that is not quite what I need. I have done it though.

I am getting better at programming vba, yay
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

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