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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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