Hi all,
The macro below deletes all duplicate rows by checking Column A for duplicate entries. It works fine for ordinary numbers but it wont work for for times and dates (i.e for data in this format 01/03/2011 07:52:04). All entries in column A are in the format dd/mm/yyyy hh:mm:ss. How to I modify the code to do this. I tried declaring the variable x As date but it doesn't work. Any ideas please?
Sub DeleteDups()
Dim x As Long
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range("A1:A" & x), Range("A" & x).Text) > 1 Then
Range("A" & x).EntireRow.Delete
End If
Next x
End Sub
The macro below deletes all duplicate rows by checking Column A for duplicate entries. It works fine for ordinary numbers but it wont work for for times and dates (i.e for data in this format 01/03/2011 07:52:04). All entries in column A are in the format dd/mm/yyyy hh:mm:ss. How to I modify the code to do this. I tried declaring the variable x As date but it doesn't work. Any ideas please?
Code:
Dim x As Long
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range("A1:A" & x), Range("A" & x).Text) > 1 Then
Range("A" & x).EntireRow.Delete
End If
Next x
End Sub
Code: