Debugs with Copy / Paste

J

John

I have the following code that Debug on the "ActiveSheet Paste" that is in large font below and I can't figure it out. The Debug message is "Paste Method of Worksheet Class failed"




Sub Generate_Reports()

Sheets("Figures").Select
Cells.Select
Selection.Copy
Range("A1").Select
Sheets("E-Figures").Visible = True
Sheets("E-Figures").Select
Range("A1").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Paste
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False
Sheets("Altered").Select
Cells.Select
Selection.Copy
Range("A1").Select
Sheets("E-Altered").Visible = True
Sheets("E-Altered").Select
Range("A1").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Paste
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False

Sheets("Home").Select
Range("A1").Select

Mail_Reports
End Sub
 
J

Jim Rech

Whenever you try to paste, if it does not say "Select destination and press
ENTER or choose paste" in Excel's lower left corner, you know that the
clipboard has been cleared. (You can check this when you hit Debug). So
there is nothing to paste. The actions of unhiding a worksheet or
unprotecting it have done this. So do them before you do the Copy.

--
Jim
I have the following code that Debug on the "ActiveSheet Paste" that is in
large font below and I can't figure it out. The Debug message is "Paste
Method of Worksheet Class failed"




Sub Generate_Reports()

Sheets("Figures").Select
Cells.Select
Selection.Copy
Range("A1").Select
Sheets("E-Figures").Visible = True
Sheets("E-Figures").Select
Range("A1").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Paste
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False
Sheets("Altered").Select
Cells.Select
Selection.Copy
Range("A1").Select
Sheets("E-Altered").Visible = True
Sheets("E-Altered").Select
Range("A1").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Paste
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False

Sheets("Home").Select
Range("A1").Select

Mail_Reports
End Sub
 

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