请问:在VBA怎样判断在Excel选定区域内是否存在某字符串?

如题所述

第1个回答  2011-12-21
'实现指定单元区域,条件查询
Set a = Application.InputBox("输入查询区域", "区域", Type:=8) '输入查询区域
intext = InputBox("输入查询关键字", "关键字查询") '输入查询关键字
With a.Select
For Each b In a
Set F = b.Find(intext, LookIn:=xlValues)
If Not F Is Nothing Then
MsgBox "存在查询关键字" '这里输入你想执行的方法
End If
Next
End With
第2个回答  2011-12-16
excel中的函数vba都可以调用;
之前在excel中如何判断,这里也可以,函数前加application。

WorksheetFunction.IsErr (Application.find("字符",range)) 为true 找不到本回答被提问者采纳
相似回答