Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy & Paste Range from 1 workbook to another

Status
Not open for further replies.

JaneB19

Technical User
Jun 27, 2002
110
GB
Hi,

I've already had a look through some of the old threads along the same lines, unfortunately none of the ones that I found could help.

What I'm wanting to do is copy several ranges of data (I'll probably have to do each seperately) from a protected form on a spreadsheet, and put these ranges into a spreadsheet in a different workbook. This would probably work fine using the normal copy and paste methods, but the form that the data is being copied from is selected by the user and is not in a predefined list!

I have tried the following code:

Workbooks(FileToOpen).Worksheets("Coiled Tubing").Range("B8:B14").Copy Workbooks("Excel Database").Worksheets("Coiled Tubing").ActiveRange("A:G").PasteSpecial(xlPasteValues)


where FileToOpen is the file opened by the user.The following error occurs when I get to the copying part of my coding:

Run-time error '9':
Subscript out of range


Can anybody help me sort this problem out? If you'd like the whole of the coding just let me know! :)

Thanks in advance
Jane

[PC2]
 
Jane,

"Subscript out of range" relates to an Array subscript (record in an Array). Without the entire code it's difficult to say further.

Please re-post with full code.

Leigh Moore
LJM Analysis Ltd
 
just some thoughts...

The paste area is different to the copied area!

Does "Excel Database" really exist?
 
Hi, sorry it's taken me so long to reply but I've been on vacation.

Thanks for your replies. Yes "ExcelDatabase" exists, the spreadsheets are in seperate workbooks. Which was what was causing me problems.

I've since managed to get the problem sorted

Thanks again [bigsmile]

Jane

[PC2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top