remove duplicate value but keep rest of the row values

☆樱花仙子☆ 提交于 2019-12-06 05:38:23

问题


I have a excel sheet(csv) like this one:

and I want the output(tab delimited) to be like this:

Basically:

  • replace duplicates with blanks but
    • if col6 value is different from the previous row for the same col1 value, all the data fields should be included.

I am struggling to create a formula which would do this. If I try to "Remove Duplicates" it removes the value and shifts the values up one row. I want it to remove the duplicates but not shift the values up.


回答1:


Try this (note, you need a blank top row (edit: Actually, you're fine you have a header row)):

=IF(A2<>A1,A2,IF(D2<>D1,A2,""))
=IF(A2<>A1,B2,IF(D2<>D1,B2,""))
=IF(A2<>A1,C2,IF(D2<>D1,C2,""))
etc

in the top row and drag down

Edit: Noticed you needed an additional condition.




回答2:


Given that duplicate data cells are next to each other

and data are on column A with blank top row, this should work. It will remove duplicates except the first occurrence.

=IF(A1=A2,"",A2)

=IF(A2=A3,"",A3)

.

.

.




回答3:


Try this

=IF((COUNTIF(A1:A$203,A1))=1,A1,"")

It will count duplicates and for the last count it will keep value.

Try COUNTIF(A1:A$203,A1) and you should be good to understand the logic.




回答4:


You asked for a formula? I suppose you could do something like this. Although it might be easier to use a macro:

=IF(COUNTIF($A$2:A6,"=" & A7),"",A7)

You could have a duplicate table on a separate tab using this formula to clear the rows you don't need - or however you want. Good Luck.




回答5:


There is another way that doesn't involve a helper column... conditional formatting.

Highlight A2:G(whatever the last cell is)

Use a formula to decide which cells to highlight

Formula would be =AND($A2=$A1,$F2=$F1)

Set the format to be white text (or equal to whatever you have the background color)



来源:https://stackoverflow.com/questions/17748658/remove-duplicate-value-but-keep-rest-of-the-row-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!