Bypass An Error

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,538
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I use this code :

Rich (BB code):
    Else
        rTarget.Fill.ForeColor.RGB = RGB(255, 255, 255) 'ON to OFF
        p1 = wshvar.Range("T3:T500").Find(What:=rTarget.Name).Address
        wshvar.Cells.Range(p1).Delete xlUp
    End If

However, sometimes the value doesn't exist in the range to find, so there is an error.
How can I overcome this?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Little tricky without knowing what else might be in your code, but try this
Code:
Else
    rTarget.Fill.ForeColor.RGB = RGB(255, 255, 255) 'ON to OFF
    On Error Resume Next
    p1 = wshvar.Range("T3:T500").Find(What:=rTarget.Name).Address
    On Error GoTo 0
    If p1 <> "" Then
      wshvar.Cells.Range(p1).Delete xlUp
    End If
End If
 
Upvote 0
Hi Peter ... that was what was needed. Thank you!

Jenn
 
Upvote 0

Forum statistics

Threads
1,203,146
Messages
6,053,755
Members
444,681
Latest member
Nadzri Hassan

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