Tuesday, September 3, 2013

Delete rows using Loop

VBA code to loop thru rows within column and delete rows containing a certain value:

Dim LastRow As Long 
Dim I As Long 
LastRow = Range("D" & Rows.Count).End(xlUp).Row 
For I = LastRow To 2 Step -1  'Change the row number
    Set rng = Range("D" & I) 
    If rng.Value= "ABC" Then   'Change the condition
    End If 
Next I 

No comments:

Post a Comment