0

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.

thanks

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
chrnit
  • 17
  • 2
  • 8

1 Answers1

1

The first problem is that your line:
searchAdress = .Find("USD", LookIn:=xlValues)

Should be :
Set searchAdress = .Find("USD", LookIn:=xlValues)
The Set command is required for object variables.

Your next problem is that your MsgBox will not work. Change the line to:
MsgBox searchAdress.Address

Mr. Mascaro
  • 2,693
  • 1
  • 11
  • 18