• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Deleting Duplicate rows

Hi Experts,

I found a code in below link for deleting duplicate rows using dictionary method. But i am not able correlate these lines - "Application.Index(sn, j, 0)" and "Application.Index(.items, 0, 0) " . Hope someone will put some light on it.

http://www.snb-vba.eu/VBA_Dictionary_en.html#L_22


Code:
Sub M_delete_duplicates()
sn = Sheets("Sheet1").Cells(1).CurrentRegion.resize(,5)

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

Sheets("Sheet1").Cells(1, 4).Resize(.Count, UBound(sn, 2)) = Application.Index(.items, 0, 0)
End With
End Sub
 
Be aware that slicing and dicing arrays like this often slower (in the order of 10 times) than looping; I've had occasions to test this. Do your own testing.
Also, if you use Index or Tranpose, check that dates aren't converted to strings, which might then be misinterpreted by Excel when writing those strings to a sheet.
 
Last edited:
Back
Top