ListRows & Skipping Rows

Abulafia

Board Regular
Joined
Jun 15, 2004
Messages
66
I have a table on a sheet. The table (called TBL_Data) has three columns.

The table is assigned to a ListObject object, called loData.

The problem I seem to be having is that when I loop through the items in the table I am finding that the lr.Range appears to be skipping a row.

Code:
Dim lngCounter As Long
Dim lngRows As Long
Dim lr As ListRow

lngRows = loData.ListRows.Count

    For lngCounter = 1 To lngRows 
    
        Set lr = loData.ListRows.Item(lngCounter)
    
        Debug.Print Format(lr.Index, "00") & " | " & lr.Range.Address & " | " & lr.Range(lngCounter, 1) & " | " & lr.Range(lngCounter, 2) & " | " & lr.Range(lngCounter, 3)

    Next lngCounter

Struggling to find out why, despite all the debugging. Guessing my approach is just wrong.

Suggestions?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
A search finally found this, which works for my issue.

Code:
    Dim lr          As ListRow
    Dim lc          As ListColumn

    For Each lr In loData.ListRows
    
        For Each lc In loData.ListColumns
      
            If Intersect(lr.Range, loData.ListColumns(lc.Name).Range).Value = myCriteria Then
            
            End If
            
        Next lc
        
    Next lr
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
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