Populate multicolumn userform listbox with data only from hidden rows

Intronaut

New Member
Joined
Oct 11, 2017
Messages
7
I've adopted the following code from various sources. Column A's data is populating the listbox fine, with each entry populating its respective listindex, but Column B's data (which I'm trying to capture with the .list) is only acting on the first listindex. What do I change?

Code:
Private Sub UserForm_Initialize()Dim rng As Range
Dim LastRow As Long
Dim I As Long
Dim x As Integer
ListBox1.Clear
    LastRow = ActiveSheet.Range("A100000").End(xlUp).Row
    For I = 1 To LastRow
        Set rng = ActiveSheet.Range("A" & I)
        If rng.EntireRow.Hidden = True Then
            With ListBox1
                .AddItem rng.Value
                .List(0, 1) = Range("B" & I).Value
            End With
        End If
    Next I
End Sub

Hope my question is clear, and many thanks for any insights you can offer...
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
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