There is this old thread that provides a solution to delete duplicated rows, Delete all duplicate rows Excel vba .But if i use it on the data as shown below, that solution doesn't work as intended. Although i can add .End(xlDown) such that Set rng = Range("A1", Range("E1").End(xlDown).End(xlDown.End(xlDown) to delete the duplicated rows(Device A) that are separated in the screenshot, is there a better way to do it?
Another question that i want to clarify is what is the meaning of rng.RemoveDuplicates Columns:=Array(1, 2)? Because even if i put it as = Array(1) or even Array(1,2,3,4,5) i realised it will still delete the duplicated rows.
Sub test()
With Worksheets("Output")
Set rng = Range("A1", Range("E1").End(xlDown))
rng.RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo
End With
End Sub
Range("A1:E" & LastRow)
– Siddharth Routcontain
the duplicate information. Try this experiment. Record a macro and then select your range and then click onData|Remove Duplicates
. Now select A,C,E columns in the dialog box. Finish the process and then check the code. Repeat the process by selecting different columns and checking the code. That will make it clear on how this works :) – Siddharth Rout