Find, If found do X, If not found Next

carpjm1

New Member
Joined
Sep 12, 2014
Messages
5
Hi All. I have this operation that looks for specific text on a sheet. Sometimes this text is not present but the operation still carries out even though it is not there. How do i IF this to move on if not found? Thank you in advance!

Code:
Sheets("36Data").Select
    On Error Resume Next
    Selection.Find(What:="RF #", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Select
    ActiveCell.Offset(1, 1).Select
    Range(ActiveCell, ActiveCell.End(xlDown)).Select
    Selection.Copy
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,246
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Maybe something like this:
Code:
Dim R As Range
Sheets("36Data").Select
Set R = Selection.Find(What:="RF #", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False)
If Not R Is Nothing Then
    Range(R.Offset(1, 1), R.Offset(1, 1).End(xlDown)).Copy
    'do something w/the copy
Else
    'move on
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,109,542
Messages
5,529,438
Members
409,877
Latest member
DDhol
Top