Dynamic Range from sheet1 in Listbox1 on Userform

Qmustard

New Member
Joined
Sep 27, 2016
Messages
37
Hi all,

Looking for what I assume is an easy answer.

I have three columns on sheet1 with data.
They will dynamically change length based on how the data is inputted via other methods.

I’d like to populate my listbox1 on userform1 with this data from all three columns.

I’ve been able to do it with one column, but not with all three.

I’ve been messing with listbox1.rowsource but been unable to get it to populate only what’s in the cells.

Thanks in advance!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Make sure the "RowSource" property is blank.

Then place this code in your userform module.
Code:
Private Sub UserForm_Initialize()
With Me.ListBox1
    .ColumnCount = 3
    .List = Sheets("Sheet1").Cells(1).CurrentRegion.Resize(, 3).Value
End With
End Sub
 
Upvote 0
Make sure the "RowSource" property is blank.

Then place this code in your userform module.
Code:
Private Sub UserForm_Initialize()
With Me.ListBox1
    .ColumnCount = 3
    .List = Sheets("Sheet1").Cells(1).CurrentRegion.Resize(, 3).Value
End With
End Sub

Ah! Thank you MickG! I knew it would be something simple! Thank you! :)


What I forgot to ask, was is it possible to remove the first cells? So it starts from A2 etc..?
 
Last edited:
Upvote 0
Try this:-
Code:
Private Sub UserForm_Initialize()
Dim Rng As Range
Set Rng = Cells(1).CurrentRegion.Resize(, 3)
With Me.ListBox1
    .ColumnCount = 3
    .List = Rng.Offset(1).Resize(Rng.Rows.Count - 1, 3).Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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