惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
C
Cybersecurity and Infrastructure Security Agency CISA
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
Securelist
S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 热门话题
博客园 - 三生石上(FineUI控件)
T
Threatpost
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
IT之家
IT之家
P
Palo Alto Networks Blog
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
Cyberwarzone
Cyberwarzone
腾讯CDC
L
LangChain Blog
Know Your Adversary
Know Your Adversary
C
CXSECURITY Database RSS Feed - CXSecurity.com
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
T
Tor Project blog
AWS News Blog
AWS News Blog
T
Tenable Blog
NISL@THU
NISL@THU
Security Latest
Security Latest
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
美团技术团队
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog

博客园 - 浪地

SQL SERVER 与ACCESS、EXCEL的数据转换 水晶报表注册码 Request.ServerVariables的参数解析 - 浪地 - 博客园 Javascript中的函数替代ASP.NET的Server.UrlEncode C#实现的18位身份证格式验证算法(转) - 浪地 - 博客园 从SQL Server数据库提取图片并显示在DataGrid - 浪地 - 博客园 ASP.NET热点问题解答14个 把图片保存到sql server数据库里 JavaScript使用技巧精萃 - 浪地 - 博客园 T-SQL游标使用 SQL中通配符、转义符与"["号的使用 两台SQL Server数据同步解决方案 SQL Server中各个系统表的作用 SQL连接查询 SQL Server实用经验与技巧大汇集 SQLServer基本函数 从 HTTP 上下载文件示例 ASP.NET中17种正则表达式(转) C#打包SQL数据库部署安装(原创啊)
删除excel中重复的数据 - 浪地 - 博客园
浪地 · 2007-06-18 · via 博客园 - 浪地

经常碰到excel中重复的数据,如果数量不多,手工删除或许尚可,如果数据比较大,就需要借助计算机拉,一般有两种方法,一种是用Excel中的高级筛选工具,另一种就是我下面说的,利用vb脚本实现,或许更好用些。

1.函数1

Sub deleteDouble()

     '用户输入提示
     Dim userInput
         userInput = Application.InputBox("输入需要检查的起始行,结束行,以及需要检察的列,格式如 1,20,C")
    
     Dim arrUserInput
         arrUserInput = Split(userInput, ",")
        
     Dim theColumn
         theColumn = Asc(arrUserInput(2)) - 64    '需要进行检验的列
        
     Dim theStart
         theStart = arrUserInput(0)   '数据的起始行
        
     Dim theEnd
         theEnd = arrUserInput(1) '最后一行数据的号码.
    
     Dim i    '每一行的号码
     Dim j    '
     For i = theStart To theEnd   '循环处理过程,如果数据比较大,可能耗费时间较多
         For j = i + 1 To theEnd '从当前行至结尾.
             If Cells(i, theColumn) = Cells(j, theColumn) Then
                 Rows(j).Delete
             End If
         Next
     Next
    
End Sub

2.函数2

用宏处理这样的问题相对方便一点,有兴趣试试:

一、按ALT+F11 打开VB编辑器

二、双击左边靠上的【工程资源管理器】中的【MS Excel 对象】中的ThisWorkbook,在右边的代码窗口贴入下面的代码:

Sub 删除重复数据()
'删除col列的重复数据
'本例是删除标题为sheet1的EXCEL表中A列(从A2单元格开始)的重复数据
Application.ScreenUpdating = False
'可根据实际情况修改下面三行的结尾值
Dim sheetsCaption As String: sheetsCaption = "Sheet1"
Dim Col As String: Col = "A"
Dim StartRow As Integer: StartRow = 2

'以下不需要修改
Dim EndRow As Integer: EndRow = Sheets(sheetsCaption).Range(Col & "65536").End(xlUp).Row
Dim Count_1 As Integer: Count_1 = 0
Dim count_2 As Integer: count_2 = 0
Dim i As Integer: 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