Excel如何在3个相同值的多个中删除重复行

发布于 2025-02-07 13:46:01 字数 436 浏览 2 评论 0原文

我想知道Excel是否有可能删除重复行,如果我具有3个相同的值,则该函数将删除2个重复并保持1,但是,如果相同的值大于3,则将保持2个重复。 等

如果它具有7个重复项,它将保留3个重复项

... rel =“ nofollow noreferrer”> “”

这就是在将重复项与删除之后的外观一样行

VBA,公式或其他Excel功能可以做到这一点吗?

I would like to know if there's a possibility for excel to remove duplicates rows if I have 3 same value, the function will remove 2 duplicate and keep 1, however if the same value is greater than 3, it will keep 2 duplicates. If it has 7 duplicates, it will keep 3 duplicates and so on... For example:

This is the original data that I want to remove:

This is how it should look like after the duplicates are removed along with the rows

Can VBA, formula, or other excel feature could do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心凉 2025-02-14 13:46:01

将以下公式放入辅助柱中,例如将其放入单元格D2中并将其复制
= mod(countif($ a $ 2:$ a2,a2),3)= 1

  • countif将计算相同值的数量,直到当前行im
  • mod将此数字除以3并给您给您其余的(1,2,0,1,2,0 ...)
  • 现在将显示为第1,第4,第7 ...行相同的值和false的= 1现在显示为true所有其他行(您要删除)。

现在,过滤助手列的值false并删除所有可见行。

如果这是一个重复的过程,则可以编写VBA例程来执行此操作。

Put the following formula into a helper column, eg put it into cell D2 and copy down
=MOD(COUNTIF($A$2:$A2,A2),3)=1

  • The CountIf will count the number of same values until the current row
  • The Mod will divide this number by 3 and give you the remainder (1, 2, 0, 1, 2, 0...)
  • The =1 will now show True for the 1st, 4th, 7th... row with the same value and False for all the other rows (that you want to delete).

Now filter for the value FALSE of the helper column and delete all visible rows.

If this is a repeated process, you can write a VBA routine to do this.

青衫负雪 2025-02-14 13:46:01

您可以使用Excel公式。使用3个辅助列

  • 公式1 countifs(a:a,a2)
  • formula2 countifs($ d $ 2 $ 2:d2,d2,d2)
  • 3 Intervel iwterpal iwter> iwter>如果((e2-quotient(e2-Quotient( e2,3)*3)= 1,1,“”)

“”

You can use Excel formulas. Use 3 helper columns

  • Formula1 COUNTIFS(A:A,A2)
  • Formula2 COUNTIFS($D$2:D2,D2)
  • 3 interval IF((E2-QUOTIENT(E2,3)*3)=1,1,"")

暖树树初阳… 2025-02-14 13:46:01
=FILTER(A2:C18,MOD(ROW(A2:C18)-MATCH(A2:A18,A2:A18,0),3)=1)

如果您具有Excel 365,则假设数据已在A列上排序,并从第2行

。 “ https://i.sstatic.net/akuej.png” alt =“在此处输入图像说明”>

=FILTER(A2:C18,MOD(SEQUENCE(ROWS(A2:C18),1,2)-XMATCH(A2:A18,A2:A18),3)=1)

如果您需要过滤到就地,只需将其中的任何一个内部用作滤镜列,例如

=MOD(SEQUENCE(ROWS(A2:C18),1,2)-XMATCH(A2:A18,A2:A18),3)=1
=FILTER(A2:C18,MOD(ROW(A2:C18)-MATCH(A2:A18,A2:A18,0),3)=1)

if you have Excel 365, assuming the data is sorted on column A and starts in row 2.

enter image description here

or

=FILTER(A2:C18,MOD(SEQUENCE(ROWS(A2:C18),1,2)-XMATCH(A2:A18,A2:A18),3)=1)

If you need to filter in-place, just use the inner part of either of these as the filter column, e.g.

=MOD(SEQUENCE(ROWS(A2:C18),1,2)-XMATCH(A2:A18,A2:A18),3)=1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文