我想找出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
答案 0 :(得分:0)
你不能加入这样的范围,你需要单独搜索
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