Excel question

thirtythree

Diamond Member
Aug 7, 2001
8,680
3
0
Is there an easy way to have Excel delete all rows in which values in a particular column are repeated? That is, if a certain value appears, say, 7 times in the column, I want all but 1 of the rows with that value to be deleted, and it doesn't matter which one remains.
 

Kyteland

Diamond Member
Dec 30, 2002
5,747
1
81
I think you would have to write a macro to do this. In my version of Excel I click 'Tools -> Macro -> Visual Basic Editor' (or press Alt+F11) and then code away. You can compare cell values and delete the ones you want with a VBA script. Something like this:

RangeObject.Delete(Shift)

where Shift is a VBA specific value, either xlShiftUp or xlShiftToLeft
and RangeObject is something like Range("B3", "C4")

So this VBA code would delete cell B3 while shifting the other cells left: Range("B3").Delete(xlShiftToLeft)