📅  最后修改于: 2022-03-11 14:51:55.057000             🧑  作者: Mango
' Tests if a range contains a value
Sub TestMe()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets(1)
If Application.WorksheetFunction.CountIf(ws.Range("A2:A10"), _
ws.Range("A1")) = 0 Then
Debug.Print "No match"
Else
Debug.Print "Range contains value " & ws.Range("A1").Cells(1, 1).Value
End If
End Sub