当前位置:首页经验技巧Excel经验excel函数

excel如何过滤重复项目

2026-01-23 10:58:40

1.Excle中如何删除两个表中相同的行(附件)在Excle表格中有

操作步骤: 1、打开Excel文件,按“Alt+F11”进入VBE编辑环境; 2、“插入”-》“模块”; 3、在右侧的代码编辑区域粘贴以下代码: Option Explicit Sub mark_rept() Application。

ScreenUpdating = False Dim k As Range, c As Range, rngSource As Range Dim strAdd As String With Sheets("sheet2") 。Cells。

Interior。ColorIndex = xlNone Set rngSource = Range(。

[A1], 。Cells(。

[A1]。End(xlDown)。

Row, 1)) End With With Sheets("sheet1") 。 Cells。

Interior。ColorIndex = xlNone For Each k In Range(。

[A1], 。Cells(。

[A1]。End(xlDown)。

Row, 1)) Set c = rngSource。Find(k, LookIn:=xlValues) If Not c Is Nothing Then strAdd = c。

Address Do Range(c, c。Offset(0, 4))。

Interior。Color = RGB(Int((254 * Rnd)), Int((254 * Rnd)), Int((254 * Rnd))) Range(k, k。

Offset(0, 4))。Interior。

Color = RGB(Int((254 * Rnd)), Int((254 * Rnd)), Int((254 * Rnd))) Set c = rngSource。FindNext(c) Loop While Not c Is Nothing And c。

Address strAdd End If Next End With Application。ScreenUpdating = True End Sub Sub delt_rept() Application。

ScreenUpdating = False Dim a As Range, b As Range With Sheets("sheet1") For Each a In Range(。 [A1], 。

Cells(。[A1]。

End(xlDown)。Row, 1)) If a。

Interior。ColorIndex xlNone Then Range(a, a。

Offset(0, 4))。Delete Shift:=xlUp Next End With With Sheets("sheet2") For Each b In Range(。

[A1], 。Cells(。

[A1]。End(xlDown)。

Row, 1)) If b。Interior。

ColorIndex xlNone Then Range(b, b。Offset(0, 4))。

Delete Shift:=xlUp Next End With Application。 ScreenUpdating = True End Sub 4、关闭VBE,返回Excel表格界面,添加两个文本框,分别右键指定宏,如附件所示。

使用时,先按“标记重复数据”把重复的数据用背景色标记出来,然后使用“删除重复数据”来删除这些数据。 由于删除数据时记录指针会随着数据的删除而产生偏差,所以点击一次按钮只能删除部分重复数据,可以多次点击以完成删除工作。

特别提醒,使用前注意留一份备份,以防出现意外情况时不至于造成不必要的损失,养成好的备份习惯,有利于保护数据的完整和安全。 祝好~~ 。

2.excel中怎样查找相同项目合并

1、将全表按“型号”列为第一关键字,“产地”列为第二关键字排序。

2、增加两个辅助列(D、E列),将C2内容复制到D2,在D3输入公式:

=IF(A3=A2,IF(C3=C2,D2,C2&","&C3),C3)

将公式向下复制到相应行。

在E2输入数组公式:

=IF(ROW()=MAX(IF(A$2:A$9999=A2,ROW(A$2:A$9999))),"是","")

公式以Ctrl+Shift+Enter三键结束。

将公式向下复制到相应行。

3、、选定“型号”列,用“高级筛选”“选择不重复的记录”,“将筛选结果复制到其他地方”(假定为F列)。

3、在G列用公式对数量求和,G2单元格公式:

=SUMIF(A:B,F2,B:B)

将公式向下复制。

4、在H列用数组公式得到产地内容,H2单元格公式:

=INDIRECT("D"&MAX(IF((A$2:A$9999=F2)*(E$2:E$9999="是"),ROW(D$2:D$9999))))

公式以Ctrl+Shift+Enter三键结束。

F、G、H三列就是你要的结果。


电脑版

免责声明:本站信息来自网络收集及网友投稿,仅供参考,如果有错误请反馈给我们更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任,谢谢您的合作。
版权所有:五学知识网 Copyright © 2015-2026 All Rights Reserved .