Variable Input Range for List Box VBA

GreenyMcDuff

Active Member
Joined
Sep 20, 2010
Messages
313
Hey guys

I have a sheet with a 5 list boxes in.

I want a user to be able to select from this list. The problem is I don't know how to make the input range a variable that I can define in VBA.

Should be fairly simply... I hope.

Example:

in "Sheet1" I have a list of 10 names (Range("A1:A10"))

The drop down box will have the 10 names in it

This list then changes to 15 names (Range("A1:A15"))

After the user has pressed a refresh button I want the list box now to have those 15 names in it.


I have the code to find the size of the range:
Code:
Sub Fund_Names()
Dim Name_Count As Integer
Dim LastRow As Integer
Dim Name_Range As Range
    With Sheets("Sheet1")
 
        .LastRow = Cells(Rows.Count, 1).End(xlUp).Row
        .Name_Count = LastRow
        .Name_Range = Range("A1:A" & Name_Count)
 
    End With
 
End Sub

Just need to assign it to the list box, and I'm not sure how :S

Thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
OK well, I managed to find out after having forgotten about the record macro button :S

Still having difficulty syntaxing this part correctly:

Code:
.ListFillRange = "Sheet1'! A12:A &LastRow&"

Any ideas? LastRow is an Integer Variable

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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