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

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 张荣华

摩托车买车学车流水账 我的2016年 AutoHotKey实现将站点添加到IE的Intranet本地站点 如何通过***自动更新Chrome - 张荣华 写给大家看的设计书 VSS每次打开都需要服务器账号和密码的解决方法 好的工作习惯 某CRM项目招投标工作的感悟 读书笔记---PMBOK第五版官方中文版 善用佳软,打造高效率的办公环境 怎么在Microsoft Project中冻结列 我的家庭保险方案推荐 如何修改Total Commander配件文件的位置 豆瓣统计-2015 读书笔记---《火球:UML大战需求分析》 博客编写客户端分享 IT人员如何保护视力 SublimeText3下的Python开发环境配置 从Evernote迁移到Wiz 读书笔记---《即学即用财务常识120例》
如何在Excel中通过VBA快速查找多列重复的值
张荣华 · 2016-07-20 · via 博客园 - 张荣华

今天项目组的一个同事问我如何快速的找到一个Excel中第3列和第5列的值完全重复的值,我想了想虽然Excel中自带查找重复值的功能,但是好像只能对同一列进行比较,所以就写了一个VBA进行处理,VBA非常简单,但效果不错。

Sub FindDuplicatesInColumn()

    Dim lastRow As Long
    Dim matchFoundIndex As Long
    Dim iCntr As Long
    lastRow = 500
    
    ' 初始化临时列, 第7列用来存放结果,第8列将3 5两列的值拼接起来,方便判断
    For iCntr = 2 To lastRow
        Cells(iCntr, 7) = ""
        Cells(iCntr, 8) = Cells(iCntr, 3) & Cells(iCntr, 5)
    Next iCntr
    
    For iCntr = 2 To lastRow
        If Cells(iCntr, 5) <> "" Then
            ' 判断是否存在相等的拼接后的列,如果存在,则记录到结果中
            matchFoundIndex = WorksheetFunction.Match(Cells(iCntr, 8), Range("H1:H" & lastRow), 0)
            If iCntr <> matchFoundIndex Then
                Cells(iCntr, 7) = "Duplicate with " & matchFoundIndex
            End If
        End If
    Next iCntr
End Sub