View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
keithb keithb is offline
external usenet poster
 
Posts: 44
Default copy from one workbook to another?

Thanks Norman, your solution works; however, I am left with a question:

In your statement:

myRange1.Copy Destination:=myRange2(1)

How is myRange2(1) different from myRange2 without the "(1)" suffix?

Thanks again,

Keith



"Norman Jones" wrote in message
...
Hi Keith,

If I correctly understand your intention, try:

Set myRange1 = Workbooks(sWB1).Worksheets("Sheet1"). _
Range("A1").CurrentRegion.Columns(1)

Set myRange2 = Workbooks(sWB2).Worksheets("Sheet1"). _
Range("A1").CurrentRegion

myRange2.ClearContents

myRange1.Copy Destination:=myRange2(1)

Note that is is usually unnecessary and inefficient to make selections.

---
Regards,
Norman



"keithb" wrote in message
...
what is the code for copying a range of rows and columns from one
workbook to different rows and columns in a different workbook? The last
line of code shown below results in "Runtime Error 1004,
Application-defined or object-defined error."

Workbooks(sWB1).Activate
Set myRange1 =
ActiveWorkbook.Worksheets("Sheet1").Range("A1").Cu rrentRegion.Columns(1)
myRange1.Copy
Workbooks(sWB2).Activate
Set myRange2 =
ActiveWorkbook.Worksheets("Sheet1").Range("A1").Cu rrentRegion
myRange2.Delete
Set myRange2 = ActiveWorkbook.Worksheets("Sheet1").Range("A1")
myRange1.Copy (myRange2)

Thanks,

Keith