String in a range
Hi Dan.
MsgBox Application.CountIf(Rng2, sStr) 0
Should have been:
MsgBox Application.CountIf(Rng2.Value, sStr) 0
Another possibility might be::
'=============
Public Sub Tester2()
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range
Dim blFound As Boolean
Const sStr As String = "ABC"
Set SH = ActiveSheet
Set Rng = SH.Range("A1:A10")
For Each rCell In Rng.Cells
If InStr(1, rCell.Value, sStr, vbTextCompare) 0 Then
blFound = True
Exit For
End If
Next rCell
MsgBox Prompt:="The string " & Chr(34) & sStr _
& Chr(34) & " was found = " & blFound
End Sub
'<<=============
You could also use the Find method.
---
Regards,
Norman
|