问题描述
我想在下面提到的代码中找到包含值USD的单元格的地址。但是,系统会抛出一个错误91,指出对象变量尚未设置。我在错误91上找到一些在线信息,但我仍然不知道如何设置正确的对象。帮助是赞赏。
i would like to find the address of the cell containing the value "USD" in below mentioned code. though, the system throws me an error 91 saying that an object variable has not been set. i found some info online on error 91 but i still don't get where and how to set the right object. help is appreciated.
谢谢
Sub searchAdress()
Dim searchAdress As Range
With Workbooks("Umrechnungskurse1.xlsm").Sheets("Tabelle1").Range("A2:S2")
searchAdress = .Find("USD", LookIn:=xlValues)
End With
MsgBox searchAdress
End Sub
推荐答案
第一个问题是你的行:
searchAdress = .Find(USD,LookIn:= xlValues)
The first problem is that your line:searchAdress = .Find("USD", LookIn:=xlValues)
应该是:
设置searchAdress = .Find(USD,LookIn:= xlValues) code>
对象变量需要设置
命令。
您的下一个问题是您的 MsgBox
将无法正常工作。将行更改为:
MsgBox searchAdress.Address
Your next problem is that your MsgBox
will not work. Change the line to:MsgBox searchAdress.Address
这篇关于使用With,Range和.Find时出现vba错误91的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!