excel vba range contains

The solution for “excel vba range contains” can be found here. The following code will assist you in solving the problem.

‘ 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”
Debug.Print “Range contains value ” & ws.Range(“A1”).Cells(1, 1).Value
End If
End Sub

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts