Listbox with header option

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Code:
Dim re As Range, J As Long, jj As Long6 With Sheets("list").Range("a:a").CurrentRegion.Resize(, 15)
ReDim a(1 To .Rows.Count, 1 To 15)
For J = 1 To .Rows.Count
For jj = 1 To .Columns.Count
a(J, jj) = .Cells(J, jj).Text
Next
Next
End With
With ListBox1
.ColumnCount = 15
.ColumnWidths = "0;60;60;120;120;0;0;0;0;0;0;0;100;100;0"
End With
Me.ListBox1.List = a

Hello,
Good Day,
How we can populate the datas with header on listbox if first row has headers on worksheet?
Or if I put labels on userform as headers is it possible to populate datas from starting row2?
Many thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I would personally use ListBox2 and place it right above ListBox1
and try this code..
Code:
Private Sub UserForm_Initialize()
Dim re As Range, J As Long, jj As Long
[COLOR=#ff0000]Dim rng As Range, b As Variant
Set rng = Sheets("list").Range("a:a").CurrentRegion.Resize(, 15)
b = rng.Resize(1)
Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)[/COLOR]
With [COLOR=#ff0000]rng[/COLOR]
    ReDim a(1 To .Rows.Count, 1 To 15)
    For J = 1 To .Rows.Count
    For jj = 1 To .Columns.Count
    a(J, jj) = .Cells(J, jj).Text
    Next
    Next
End With
With ListBox1
    .ColumnCount = 15
    .ColumnWidths = "0;60;60;120;120;0;0;0;0;0;0;0;100;100;0"
End With
[COLOR=#ff0000]With ListBox2
    .ColumnCount = 15
    .ColumnWidths = "0;60;60;120;120;0;0;0;0;0;0;0;100;100;0"
End With[/COLOR]

Me.ListBox1.List = a
[COLOR=#ff0000]Me.ListBox2.List = b[/COLOR]
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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