Hi -
I am creating a macro to manipulate a large report. And at the end of my macro I want to remove duplicates excluding my header rows, There are four header rows. Finding possible solutions on forums, everything I am trying isn't working properly.
This is removing more than just duplicates in my data
With ActiveSheet.UsedRange
.Resize(.Rows.Count - 4).Offset(4, 0).RemoveDuplicates Columns:=8
End With
And this is removing a row out of my headers
Dim FirstCell As Range, LastCell As Range
Set LastCell = Cells(Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column)
Set FirstCell = Cells(Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlRows, _
SearchDirection:=xlNext, LookIn:=xlValues).Row, _
Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, LookIn:=xlValues).Column)
Range(FirstCell, LastCell).Select
With ActiveSheet.UsedRange
.Resize(.Rows.Count - 1).Offset(4).Select
End With
Range(FirstCell, LastCell).RemoveDuplicates Columns:=8
I am creating a macro to manipulate a large report. And at the end of my macro I want to remove duplicates excluding my header rows, There are four header rows. Finding possible solutions on forums, everything I am trying isn't working properly.
This is removing more than just duplicates in my data
With ActiveSheet.UsedRange
.Resize(.Rows.Count - 4).Offset(4, 0).RemoveDuplicates Columns:=8
End With
And this is removing a row out of my headers
Dim FirstCell As Range, LastCell As Range
Set LastCell = Cells(Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _
Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Column)
Set FirstCell = Cells(Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlRows, _
SearchDirection:=xlNext, LookIn:=xlValues).Row, _
Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, LookIn:=xlValues).Column)
Range(FirstCell, LastCell).Select
With ActiveSheet.UsedRange
.Resize(.Rows.Count - 1).Offset(4).Select
End With
Range(FirstCell, LastCell).RemoveDuplicates Columns:=8