question

KenKing-2364 avatar image
0 Votes"
KenKing-2364 asked

Excel macro using Find function

I am a novice in VBA and I am trying to create a complex (for me) macro for an Excel 2013 file.

I am trying to use the Find function and I am getting different results when I run the same macro a number of times.

When I first open the worksheets involved and run the following code it works.

Dim city As String
city = Range("C" & masrowno)
Sheets("Eureka").Select
Range("A1").Select
Cells.Find(What:=city, After:=ActiveCell, LookIn:=xlValues, LookAt
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=

False, SearchFormat:=False).Activate

But at some point, while I am trying to perfect the rest of the macro, it stops working with either

Run-time error '91' most often OR
Run-time error '13' occasionally

Once I get the error I can't get it to run properly again.

I have used

Cells.Find AND
Selection.Find

But again, once I get the error I can't get it to run properly again.


I have used Find in other very simple macros and don't have any problems.

What might I be missing in this macro?


office-scripts-excel-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers