Run-time error 1004 paste method of worksheet class failed


Joined
Mar 25, 2019
Messages
3
Reaction score
0
Code:
Sub save()
'
' save Macro
'
' Keyboard Shortcut: Ctrl+s
'
    Range("A4").Select
    Selection.Copy
    Sheets("database01").Select
    Sheets("database01").Unprotect Password:="pinto2019"
    Range("A1").Select
    Selection.End(xlDown).Offset(1, 0).Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("B4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("C4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 2).Range("A1").Select
    Sheets("Keyin01").Select
    Range("E4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("F4").Copy
    Sheets("database01").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("G4").Copy
    Sheets("database01").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, 5).Range("A1").Select
    Sheets("Keyin01").Select
    Range("L4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 2).Range("A1").Select
    Sheets("Keyin01").Select
    Range("N4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 2).Range("A1").Select
    Sheets("Keyin01").Select
    Range("P4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 4).Range("A1").Select
    Sheets("Keyin01").Select
    Range("T4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 2).Range("A1").Select
    Sheets("Keyin01").Select
    Range("V4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 3).Range("A1").Select
    Sheets("Keyin01").Select
    Range("Y4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("Z4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("Keyin01").Select
    Range("AA4").Copy
    Sheets("database01").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    ActiveCell.Offset(0, 1).Range("A1").Select
    Sheets("database01").Protect Password:="pinto2019"
    Sheets("Keyin01").Select
    Range("A4").ClearContents
    Range("B4").ClearContents
    Range("C4").ClearContents
    Range("E4").ClearContents
    Range("F4").ClearContents
    Range("G4").ClearContents
    Range("L4").ClearContents
    Range("N4").ClearContents
    Range("P4").ClearContents
    Range("T4").ClearContents
    Range("V4").ClearContents
    Range("Y4").ClearContents
    ActiveWorkbook.save
End Sub
 
Last edited by a moderator:
Ad

Advertisements

Ian

Administrator
Joined
Feb 23, 2002
Messages
19,040
Reaction score
1,039
Welcome to the forum, can you please give us a bit more information about your error. You haven't even mentioned which software you are using (but I guess this is Excel?).
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top