Excel VBA 查找字符串:错误 2015 [英] Excel VBA find string : Error 2015
本文介绍了Excel VBA 查找字符串:错误 2015的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须遵循代码片段...
I have to following code snippet ...
Public Sub FindText(path As String, file As String)
Dim Found As Range
myText = "test("
MacroBook = ActiveWorkbook.Name
' Open the File
Workbooks.Open path & file, ReadOnly:=True, UpdateLinks:=False
For Each ws In Workbooks(file).Worksheets
With ws
Set Found = .UsedRange.Find(What:=myText, LookIn:=xlFormulas, _
LookAt:=xlPart, MatchCase:=False)
If Not Found Is Nothing Then
' do stuff
' ...
我在调试器中看到 Found 包含错误 2015!该工作表包含我想要的公式中的文本.
I see in the debugger that Found contains Error 2015! The sheet contains the text I want in the formula.
任何想法为什么我会收到错误?
Any ideas why I'm getting the error?
谢谢
推荐答案
随着对 Q 的评论跟进,Error 2015
发生,因为您在工作表中的公式返回 #VALUE!代码>错误.您可以使用
IsError
来处理它:
As follow up from comments to the Q, Error 2015
occurs because your formula in the sheet returns #VALUE!
error. You can handle it using IsError
:
If Not Found Is Nothing Then
If Not IsError(Found) Then
' do sth
End If
End If
这篇关于Excel VBA 查找字符串:错误 2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文