📜  excel vba 范围包含 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:55.057000             🧑  作者: Mango

代码示例1
' 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