Originally Posted by
lucas
this will copy the data to the data sheet and then delete all rows(in the data sheet) that have duplicate info in Col A except 1...
[vba]
Option Explicit
Sub CopyAndRemoveDups()
Dim cl As Range
Dim ws As Worksheet
Dim x As Long
Dim LastRow As Long
Dim rng As Range
Dim rngToDelete As Range
Set ws = Worksheets("query")
With ws
For Each cl In .Range("A2:A" & .Range("A65536").End(xlUp).Row)
If cl.Value <> "" Then
cl.EntireRow.Copy Worksheets("data").Range("A65536").End(xlUp).Offset(1, 0)
End If
Next cl
End With
Set ws = Worksheets("data")
'Advanced Filter requires a header row - let's add a temporary one
ws.Rows(1).Insert
ws.Cells(1, 1).Value = "temp header"
Set rng = ws.Range("A1:A10000")
rng.AdvancedFilter xlFilterInPlace, unique:=True
Set rngToDelete = rng.SpecialCells(xlCellTypeVisible)
ws.ShowAllData
rngToDelete.EntireRow.Hidden = True
rng.SpecialCells(xlCellTypeVisible).EntireRow.Delete
rngToDelete.EntireRow.Hidden = False
'remove the temporary row
ws.Rows(1).Delete
End Sub[/vba]
see attached....add data to the query sheet to see this work as all of the info you now have in the query sheet is a duplicate except the row 31-Oct-06.