gpt4 book ai didi

vba - 如何在 Excel VBA 中匹配/搜索 Sheet2.Range ("A1"中 Sheet1.Range ("A1:A10") 的值

转载 作者:行者123 更新时间:2023-12-04 21:57:13 24 4
gpt4 key购买 nike

假设我在 Sheet1.Range("A1") 中有这个值“ABC123”

我想在 Sheet2.Range("A1:A10")//或列中搜索/匹配这个值

If the value is found
//msgbox "Found"
else
//msgbox "Not found"
end if

最佳答案

尝试这个:

Sub foo()
Dim t As Long
On Error Resume Next
t = Application.WorksheetFunction.Match(Worksheets("Sheet1").Range("A1"), Worksheets("Sheet2").Range("A:A"), 0)
On Error GoTo 0
If t > 0 Then
MsgBox "Found"
Else
MsgBox "Not found"
End If
End Sub

关于vba - 如何在 Excel VBA 中匹配/搜索 Sheet2.Range ("A1"中 Sheet1.Range ("A1:A10") 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42252366/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com