0

I have the following code that works well except that in the case where there is nothing to paste, the code stops on the "Paste" option so I added "On Error Resume Next".

Now the macro is crashing if it finds the exception. Is it on my last line? Is there something besides "On Error GoTo 0"?

On Error Resume Next

    Range("A7:CI26").Select

    Selection.Copy

    Application.CutCopyMode = False

    ActiveSheet.UnProtect Password:="zxc"

    Selection.Copy

    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

        :=False, Transpose:=False    

    Selection.Copy

    With ActiveSheet.Previous

        .Activate

        .Range("A50").Select

        .Pictures.Paste    

    End With

    Range("A1").Select

    With ActiveSheet.Next

        .Delete

        End With

    closedBook.Close SaveChanges:=False

    Range("A1").Select

    ActiveWindow.ScrollRow = 1

    On Error GoTo 0

    Next i
CarmenV
  • 25
  • 6
  • Use [proper](https://stackoverflow.com/questions/6028288/properly-handling-errors-in-vba-excel) error handling instead of `On Error Resume Next` – Warcupine Aug 30 '21 at 15:10
  • [How to avoid copy paste](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1) – HackSlash Aug 30 '21 at 16:40

0 Answers0