View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Delete duplicate cell

Hi,

If I understand correctly then your sample data should end up looking like
this

DB A HF SR SCR PI
SAW DB SR DR DB DB

Try this sub

Sub Please_Delete_me()
Dim y As Long
Dim x As Variant
Dim MyRange As Range
Set MyRange = Application.Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Columns(ActiveCell.Column))
For y = MyRange.Rows.Count To 2 Step -1
x = MyRange.Cells(y, 1).Value
If Application.WorksheetFunction.CountIf(MyRange.Colu mns(1), x) 1 Then
MyRange.Rows(y).EntireRow.Delete
End If
Next y
End Sub


Mike

"PointerMan" wrote:

I have a large spreadsheet that I need to clean up. My data is kept by row,
so some rows have the same information in two adjacent cells. An example is
below in rows 2 through 5.

1 DB A HF SR SCR PI
2 SAW DB SR DR DB DB
3 SAW DB SR DR DB DB
4 SAW DB SR DR DB DB
5 SAW DB SR DR DB DB

Is there a function that can automatically delete the 2nd duplicate cell
contents? I can delete them manually one at a time, but I'd like
to be able to clean up the entire sheet at once.