Loop through table from last row to first

Factotum

Board Regular
Joined
May 14, 2015
Messages
118
Could someone help me revamp this:

HTML:
Dim c As Range
For Each c In Range("Table1[Entity Code]")
    If c.Value = "R" Or c.Value = "T"
   Then c.EntireRow.Delete
End If
Next

My current test spreadsheet has four rows (all of which should be deleted by this), but it only deletes two of them. I suspect the reason for this is because it's looping from the top down, rather than the bottom up. I just don't know how to re-write the code above so that it loops from the bottom up. I've found plenty of examples on how to do this with a regular range, but I can't find anything on how to do it in a table. Any suggestions would be greatly appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I should have looked one more time before asking. Here's the solution I came up with. May or may not be the most elegant, but it works:

Code:
Dim lngCounter As Long, rng As Range
Set rng = Range("Table1[Entity Code]")

For lngCounter = rng.Cells.Count To 1 Step -1
         If rng(lngCounter).Value = "PFBYUR" Then
               rng(lngCounter).EntireRow.Delete
         End If
Next lngCounter
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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