LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Can't paste the second time around

Good morning!

Well, I'm really stumped by this one. The macro below simply grabs data from
a worksheet in one workbook, and pastes it to a worksheet in another
workbook. If I run it once, it works fine. If I immediately then run it a
second time, I get an error "Paste method of worksheet class failed." Now,
the interesting point is that if I delete the two lines which unprotect and
protect the sheet, the macro will run fine every time. I don't get it. Can
anyone help me on this?

Thanks,

Jeff
Tucson, Arizona

Sub GetData()
'NOTE: This macro is run from "MainProgram.xls"
Workbooks.Open ("abctest.xls")
Windows("abctest.xls").Activate
Worksheets("Save Drop Locations").Select
Range("A1:D1").Select
Selection.Copy
Windows("MainProgram.xls").Activate
Worksheets("Drop Locations").Select
ActiveSheet.Unprotect 'ROUTINE RUNS FINE WHEN THIS LINE DELETED
Range("A2").Select
ActiveSheet.Paste
ActiveSheet.Protect 'ROUTINE RUNS FINE WHEN THIS LINE DELETED
Application.CutCopyMode = False
Windows("abctest.xls").Activate
ActiveWorkbook.Close
Windows("MainProgram.xls").Activate
End Sub





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste transpose and link at the same time Phippsy Excel Worksheet Functions 5 June 9th 09 03:11 PM
Copy and Paste to multiple woorksheets at one time ManhattanRebel Excel Discussion (Misc queries) 0 February 12th 09 07:16 PM
Copy and Paste only working for one cell at a time goplayoutside Excel Discussion (Misc queries) 4 February 4th 09 03:56 PM
Can you paste values on multiple worksheets at one time? JanetK Excel Worksheet Functions 1 June 12th 05 04:51 PM
Macro to Paste to specific line, and continue to Paste each time on next row not over tomkarakowski[_2_] Excel Programming 1 May 28th 04 06:50 PM


All times are GMT +1. The time now is 10:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"