车少 发表于 2008-3-27 09:59

【求助】请教excell高手!!!

有一个excell文件,有2列,几千行,我想检查其中一列,如果这一列有重复的,就只保留其中一行,其他的删除,请问如何实现?

david99 发表于 2008-3-27 11:06

先用筛选功能,然后把重复的DEL吧   我理解你是要这么做

snhr 发表于 2008-3-27 11:22

排序先,

if(x11=x10,1,0)

然后filter 删除所有1的。

完成。

车少 发表于 2008-3-27 11:32

能详细点儿吗?我只会用excell的简单功能

snhr 发表于 2008-3-27 11:39

文件发给我,我帮你搞定。

zhq76 发表于 2008-3-27 14:04

如果是2007就很方便,见图

车少 发表于 2008-3-27 16:39

谢谢大家,我先自己试试看,主要是文件比较多,自己要弄明白

ffpp 发表于 2008-3-27 18:10

最好,写个宏来干这个事情。这里有段代码。打开VBA编辑器,放到workbook中,执行这个宏就可以了。

Sub delrow()

Application.ScreenUpdating = False

Dim sheetsCaption, Col, StarRow
Dim EndRow, Count_1, Count_2, i

sheetsCaption = "Sheet1"   '定义目标sheet
Col = "A"                        '定义重复行所在列
StartRow = 2                  '定义从哪行开始


EndRow = Sheets(sheetsCaption).Range(Col & "65536").End(xlUp).Row
Count_1 = 0
Count_2 = 0
i = StartRow

With Sheets(sheetsCaption)

Do
    Count_1 = Count_1 + 1
    For j = StartRow To i - 1
      If .Range(Col & i) = .Range(Col & j) Then
            Count_1 = Count_1 - 1
            .Range(Col & i).EntireRow.Delete
            EndRow = Sheets(sheetsCaption).Range(Col & "65536").End(xlUp).Row
            i = i - 1
            Count_2 = Count_2 + 1
            Exit For
      End If
    Next
i = i + 1
Loop While i < EndRow + 1
End With

MsgBox "共有" & Count_1 & "条不重复的数据"
MsgBox "删除" & Count_2 & "条重复的数据"
Application.ScreenUpdating = True
End Sub
页: [1]
查看完整版本: 【求助】请教excell高手!!!