Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Run-time error '91': at Find statement

0

I created a VBA module identical to the one presented in "Idiot-Proof Excel - Part 6" that finds data on one worksheet and fills a form on another worksheet.

The code is written exactly the same with the exception of the worksheet names and the data that is requested. When I run the module I get the r-time error reference in the title.

The code is as follows:

Set Rng = dataIdCol.Find(What:=searchValue, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False)

Can you explain why it doesn't work? I can provide the entire module code if necessary.

Answer
Discuss

Answers

0

Hello Scotsman and welcome to the Forum.

Given your question relates to a paid course, please don't post the whole code or file on the Forum. Instead you can ask the question directly to the course author Don by using the Contact link above (and sticking with the  Subject selection "Premium Course Questions").

Before you do so, please check that (in Module 3's sub Select_Data) the Set statements (after the Dim declarations) refer to correct sheet names/ranges. I suspect that dataIdCol is not set correctly (or named differently there)- it needs to be the same as 

Set Rng = dataIdCol.Find
 

or VBA won't find an object and give an error 91.

Hope this helps

Discuss

Discussion

I did find an error in my code but once it was corrected I got -
Run-time error '1004':
Unable to get Active property of the Range class
This is where the error was before I corrected it.
Set dataIdCol = dataSheet.Range("A:A")

The following code is prior to the one above.
Dim dataIdCol As Range

What could be causing the new error?
Scotsman Apr 12, '22 at 12:09 pm
Scotsman

I don't know what you've done (or if my suggestion worked), sorry. Suggest you contact Don as I said and you can share your code with him and get an answer that way.
John_Ru (rep: 3222) Apr 12, '22 at 1:47 pm
Add to Discussion


Answer the Question

You must create an account to use the forum. Create an Account or Login