Reputation: 327
I'm looking for cells with length of value 1 or 2 characters. This is code:
Set c = .Find(Len(c.Value) = 2 Or 1, LookIn:=xlValues)
Upvotes: 0
Views: 45
Reputation: 96791
You can use a loop rather than FIND():
Sub durale()
For Each r In ActiveSheet.UsedRange
If Len(r.Value) = 2 Or Len(r.Value) = 1 Then
Set c = r
Exit For
End If
Next r
If c Is Nothing Then
MsgBox "nothing found"
Else
MsgBox "cell " & r.Address(0, 0) & "contains " & r.Value
End If
End Sub
Upvotes: 2