View Single Post
 
Old 04-03-2019, 04:01 PM
p45cal's Avatar
p45cal p45cal is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2014
Posts: 871
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

I can't reproduce your error.
Attaching a workbook where this happens would be very useful to us.

While trying to make this go wrong, I did manage to get a type mismatch error, but on the line:
Set FoundCell = SearchRange.Find(What:=FindWhat,
in the circumstances that I passed a non-contiguous range such as:
Range("$A$1:$A$3,$A$5:$A$7,$A$9:$A$10,$C$1:$C$2")
where the line:
Set LastCell =
immediately above sets LastCell to be a cell which doesn't exist in any area in the non-contiguous range to be searched. In this picture, the yellow cell is what LastCell is set to, and the grey area is the area to be searched, so in the .Find statement, After:=LastCell is not a cell in any area.




So really, if you can attach a file, with the code that makes it throw an error, it would be best. I don't even know whether you're searching non-contiguous ranges or not.

I also seem to remember from some time back that .FindNext doesn't work very well with non-contiguous ranges and I found I had to use .Find all the time with the After:= parameter set each time.
Reply With Quote