当我使用以下代码时,是否可以绕过运行时错误91 (对象变量未设置)?
Dim findE As Range
findE = Sheets(1).Range("A:AAA").Find(What:="E", searchdirection:=xlLeft, lookat:=xlWhole, searchorder:=xlByColumns).Column我的findE用于查找文本"E“,它可能不会一直出现。每当它没有出现时,它就会产生运行时错误。
我试着用
Dim findE As Range
Set findE = Sheets(1).Range("A:AAA").Find(What:="E", searchdirection:=xlLeft, lookat:=xlWhole, searchorder:=xlByColumns).Column
If not findE Is Nothing Then
'do something
end if我还是看到了错误。我确实提到了这个VBA in find function runtime error 91,但在all.Please仍然没有提供任何帮助,建议我这样做。谢谢。
发布于 2015-04-26 15:33:39
试试下面的..。
Dim FindE As Range
With Sheets(1).Range("A:AAA")
Set FindE = .Find(What:="E", SearchDirection:=xlLeft, LookAt:=xlWhole, _
SearchOrder:=xlByColumns)
If Not FindE Is Nothing Then Set FindE = Columns(FindE.Column)
End Withhttps://stackoverflow.com/questions/29878964
复制相似问题