excel - 在多个工作表中查找重复项
问题描述
我想查找 2 张纸中是否有重复项。
示例 1(适用于此工作表):
Function FindDuplicate(factnr) As Boolean
With Worksheets("Sheet 1").Range("D6:D206")
Set C = .Find(factnr, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
FindDuplicate = True
Exit Function
End If
End With
FindDuplicate = False
End Function
示例2(这是我要完成的[模拟代码],检查两张表的功能)
Function FindDuplicate(factnr) As Boolean
With Worksheets("Sheet 1").Range("D6:D206") & ("Sheet 2").Range("D6:D206")
Set C = .Find(factnr, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
FindDuplicate = True
Exit Function
End If
End With
FindDuplicate = False
End Function
解决方案
你不能像那样加入范围,你需要单独搜索每个
Function FindDuplicate(factnr) As Boolean
With Worksheets("Sheet 1").Range("D6:D206")
Set C = .Find(factnr, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
FindDuplicate = True
Exit Function
End If
End With
With Worksheets("Sheet 2").Range("D6:D206")
Set C = .Find(factnr, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not C Is Nothing Then
FindDuplicate = True
Exit Function
End If
End With
FindDuplicate = False
End Function
推荐阅读
- azure-devops - 与本地机器相比,管道构建后packages文件夹的内容不同
- dom-manipulation - 谁能告诉我为什么错误在我的代码中显示它是基本的 addeventlistener 格式
- amazon-web-services - 如何在 AWS::ElasticBeanstalk::Environment 中设置环境变量?
- swift - UIViewRepresentable 视图如何获取在父级设置的环境属性
- sql - 根据用户条件执行部分 SQL 查询
- android - 如何使用 docusign mobile-android-sdk 以编程方式将只读字段添加到 Android 上的模板?
- c++ - 没有按预期工作的简单特征(MSVC 与 gcc 和 clang)以及如何修复它
- slack - 是否可以使用新传入的 webhook 设置 icon_emoji ?
- android - “adb shell dumpsys alarm”的结果中的“tag”是什么?
- sql - SQL - 删除 [ 和 ] 之间的所有内容