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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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