View Full Version : [SOLVED:] Advance filtering unique records
av8tordude
04-16-2020, 08:09 PM
I'm trying to write a code that will filter unique records from Column A & B and pastes the unique records in column Y & Z (See attached). It flags a (run-time error 1004) message without highlighting the error. Can someone assist.
Thank you kindly
Sub mac()LRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A7:B" & LRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Y7:Z" & LRow), Unique:=True
End Sub
paulked
04-16-2020, 09:10 PM
Include the header row:
Sub mac()
LRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A6:B" & LRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Y7:Z" & LRow), Unique:=True
End Sub
Also, you only need the starting cell for your destination, so
Sub mac()
LRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A6:B" & LRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Y7"), Unique:=True
End Sub
should work too.
av8tordude
04-16-2020, 09:27 PM
When I put the code in my file, I'm still getting the error. Not sure why. See attach
paulked
04-16-2020, 09:31 PM
Sorry, but no error when I ran it.
26345
av8tordude
04-16-2020, 09:43 PM
Ok...I see what happen. I had to clear the results before filtering again. Thank you for helping me resolve this.
paulked
04-16-2020, 09:54 PM
:thumb
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.