redbaron06
New Member
- Joined
- Aug 6, 2010
- Messages
- 44
Hi all,
I have been fiddeling with this for a few day with no substantial result. I would like to be able to do exactally what the "Remove Duplicates" function on the data tab in Excel 2007 does - remove duplicates, compress the data (or remove the blanks) and sort the data within a given range.
I need to do so through VBA, without deleting whole rows. Any Suggestions. I have looked through previous selections and know this is at least partially possible without removing the blanks using:
Thanks any help is appreciated!
I have been fiddeling with this for a few day with no substantial result. I would like to be able to do exactally what the "Remove Duplicates" function on the data tab in Excel 2007 does - remove duplicates, compress the data (or remove the blanks) and sort the data within a given range.
I need to do so through VBA, without deleting whole rows. Any Suggestions. I have looked through previous selections and know this is at least partially possible without removing the blanks using:
Code:
Sub Remove_Duplicates()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
If WorksheetFunction.CountIf(Columns("A"), Range("A" & i).Value) > 1 Then Rows(i).Delete
Next i
End Sub
Thanks any help is appreciated!