I copied the following code from a microsoft example, however it removes the entire column of duplicated data. In my case, I only want to delete the data in rows 6 to 65536 of that column. How do I do that?
Can someone help me please?
The code to delete the entire column is this:-
Sub DeleteColumnDupes(strSheetName As String, strColumnLetter As String)
Dim strColumnRange As String
Dim rngCurrentCell As Range
Dim rngNextCell As Range
strColumnRange = strColumnLetter & "1"
Worksheets(strSheetName).Range(strColumnRange).Sort _
Key1:=Worksheets(strSheetName).Range(strColumnRange)
Set rngCurrentCell = Worksheets(strSheetName).Range(strColumnRange)
Do While Not IsEmpty(rngCurrentCell)
Set rngNextCell = rngCurrentCell.Offset(1, 0)
If rngNextCell.Value = rngCurrentCell.Value Then
rngCurrentCell.EntireRow.Delete
End If
Set rngCurrentCell = rngNextCell
Loop
End Sub
Can someone help me please?
The code to delete the entire column is this:-
Sub DeleteColumnDupes(strSheetName As String, strColumnLetter As String)
Dim strColumnRange As String
Dim rngCurrentCell As Range
Dim rngNextCell As Range
strColumnRange = strColumnLetter & "1"
Worksheets(strSheetName).Range(strColumnRange).Sort _
Key1:=Worksheets(strSheetName).Range(strColumnRange)
Set rngCurrentCell = Worksheets(strSheetName).Range(strColumnRange)
Do While Not IsEmpty(rngCurrentCell)
Set rngNextCell = rngCurrentCell.Offset(1, 0)
If rngNextCell.Value = rngCurrentCell.Value Then
rngCurrentCell.EntireRow.Delete
End If
Set rngCurrentCell = rngNextCell
Loop
End Sub