ActiveSheet.Paste Errors

jtk911

New Member
Joined
Sep 6, 2007
Messages
23
Help. I recorded the macro and am trying to clean it up but keep running into a problem.
Here is my very clumsy code.

Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("Credit Template").Visible = True
Sheets("Credit Template").Select
Columns("A:n").Select
Range("A2").Activate
Selection.Copy
Sheets("Credit").unprotect
Sheets("Credit").Select
Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

This code works...ONCE.
If I run it again, it fails with Run-time Error '1004': PasteSpecial Method of Range class failed.

I've tried ActiveSheet.Paste and that doesn't work either.
What am I doing wrong and how does it work once and then not again unless I reset everything?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Possibly...

Code:
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
    End With
    
    Sheets("Credit Template").Visible = True
    Sheets("Credit").Unprotect
    Sheets("Credit Template").Columns("A:N").Copy _
            Sheets("Credit").Range("a1")
    
    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
    
    Sheets("Credit").Protect
Although you do realise that it overwrites the previous data?
 
Upvote 0
Try this.

Howard


Code:
Option Explicit

Sub jtk911()
 Application.DisplayAlerts = False
 Application.ScreenUpdating = False
 Sheets("Credit").Unprotect

Sheets("Credit Template").Range("A2").Copy
Sheets("Credit").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

 Sheets("Credit").Protect
 Application.DisplayAlerts = True
 Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,413
Messages
6,136,474
Members
450,015
Latest member
excel_beta_345User

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