Hi,
Peter kindly sent me the Sub Procedure below to use in my project. The procedure is designed to remove duplicated three letter codes in a list which is periodically updated into a list in column A.
Being a novice at VBA I am just trying to get my head around the For Next structure. I understand the r of the For r part is the counter variable. LR (last range I presume) To 9 Step-1. The 9 Step -1 part, does this mean that the procedure goes up one row at a time checking the next nine rows above?
Thanks,
Rob.
Peter kindly sent me the Sub Procedure below to use in my project. The procedure is designed to remove duplicated three letter codes in a list which is periodically updated into a list in column A.
Being a novice at VBA I am just trying to get my head around the For Next structure. I understand the r of the For r part is the counter variable. LR (last range I presume) To 9 Step-1. The 9 Step -1 part, does this mean that the procedure goes up one row at a time checking the next nine rows above?
Code:
Sub Check_for_previous_occurance_of_code()
Dim LR As Long, r As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
For r = LR To 9 Step -1
If WorksheetFunction.CountIf(Columns("A"), Range("A" & r).Value) > 1 Then Rows(r).Delete
Next r
End Sub
Rob.