Resume Next

schopf86

New Member
Joined
Sep 27, 2011
Messages
2
Hey everyone,

I am having some trouble with this one. I am finishing up a very large VBA. There are three instances where I select a column, search for a particular word (i.e.- "MOVE") and select that cell.

That works perfect. The problem is when the word is not found. Once in a while, that type of record will not be present. So I need to make it possible that if Run-Time error 91 shows up due to now finding the word, it needs to ignore it and move further down the code to a new point.

Without showing the VBA, the basics are that I have a Cells.Find(abc).Select followed by the process it takes once selected. After that, it moves to a new area. I want it to ignore the error if the Cells.Find(abc) does not find abc and simply move on to the next area (skipping the process once abc would be found otherwise).

I have tried On Error Resume Next and entered Resume Next at the point in which I want the VBA to continue. But instead of moving down to resume next, the code is simply ignoring the the error and selecting a whole bunch of data I do not want selected.

Help please!!!!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hello

Welcome to MrExcel.

Have a look here:

Code:
Sub Searching()

    Dim rngFoundCell As Range
    
    Set rngFoundCell = Cells.Find(abc) 'adjust
    
    If rngFoundCell Is Nothing Then
    
        'search value was not found
        
    Else
    
        'search value was found - the variable rngFoundCell refers to that range
    
    End If
    
    Set rngFoundCell = Nothing

End Sub
 
Upvote 0
You are my hero!

I have been playing around with something similar but had missed a key part... You answered it exactly and it works perfect! thank you so much wigi!

Kevin
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top