我正在寻找长度为1或2个字符的单元格。 这是代码:
Set c = .Find(Len(c.Value) = 2 Or 1, LookIn:=xlValues)
答案 0 :(得分:2)
您可以使用循环而不是 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