View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Very Simple Copy and Paste Sheet - Error

It could be that VBA is confused by the Cells.Select since that
equates to the entire sheet. It is expecting a destination of
either After:= or a new workbook. Here is a modified version
of your code. See if it will work.


Application.ScreenUpdating = False
ActiveWindow.DisplayWorkbookTabs = False


Sheets("SheetA").Unprotect Password:="123"
Sheets("SheetB").Visible = True
Sheets("SheetB").Unprotect Password:="123"

Sheets("SheetA").Copy After:=Sheets(Sheets.Count)


"Sean" wrote:

I have a very simple piece of code (extract below), that copies the
contents from SheetA to SheetB, but I am getting a debug of "Copy
method of Range Class failed" on the line - Slection.Copy below

I can't see how my code could be any simpler and hence why the error

Hope someone can assist

Sub Report()

Application.ScreenUpdating = False
ActiveWindow.DisplayWorkbookTabs = False


Sheets("SheetA").Activate
ActiveSheet.Unprotect Password:="123"
Range("A1").Select
Sheets("SheetB").Visible = True
Sheets("SheetB").Activate
ActiveSheet.Unprotect Password:="123"

Sheets("SheetA").Activate
Cells.Select
Selection.Copy