Help with FindNext error


S

SLW612

Hello, I have the following code in my workbook and it used to work fine
(from what I remember from working on it last week), but now I am getting an
error message that says "Unable to get the FindNext property of the Range
class" - I have a feeling it has something to do with the asterisk, but I'm
not entirely positive. Could someone please help me out? Thank you in
advance!

Sub RunMeFirst()
Dim rngFound As Range
Dim rngToSearch As Range
Dim strFirstAddress As String
Dim wks As Worksheet

Set wks = ActiveSheet

With wks

Set rngToSearch = Sheets("Sheet1").Columns("K:T")
Set rngFound = rngToSearch.Find(What:="Account Category:*", _
LookAt:=xlWhole, _
LookIn:=xlValues, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Not Found"
Else
strFirstAddress = rngFound.Address

Do
rngFound.Select
Call ThisWorks2
'>>>This next line is where the debug points:
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until strFirstAddress = rngFound.Address
End If
End With

End Sub
 
Ad

Advertisements

J

JLGWhiz

More likely the problem lies in ThisWorks2, but hard to tell since it is not
also posted.
 
S

SLW612

Ah, thank you! That was indeed the problem, another macro I had called out
within ThisWorks2 - just had it called out in the wrong place.

Thanks JLG!
 
Ad

Advertisements

J

JE McGimpsey

This works fine for me (with a dummy ThisWorks2). Any reason you have to
select rngFound rather than use the range object directly?

Certainly if ThisWorks2 dereferences rngFound (e.g., deletes the row),
then .FindNext(rngFound) will error...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top