copy a range of values to another range

luolovepi

Board Regular
Joined
Jun 9, 2011
Messages
116
I face a problem copying a range of values from one workbook to another workbook.

Code:
GLB_rngToPaste.Value = GLB_rngToCopy.Value

I confirm that GLB_rngToCopy has gotten the correct range of values.
But GLB_rngToPaste only received the first value of GLB_rngToCopy range.

I tested this kind of rang to range assignment in the same worksheet, it could work. Can't it apply to ranges in different workbook or worksheet?

Rgds,
lolo
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Look at this sample to see if it helps.

Sub mcrNamedRange()
Range("GLB_rngToPaste").Copy
Workbooks.Open "Path etc .xls"
Range("GLB_rngToCopy").PasteSpecial xlPasteAll

End Sub
 
Upvote 0
Code:
Sub Paste_Script()
Workbooks.Open Filename:= _
        "C:\Stationary\Book1.xls", UpdateLinks _
        :=0
    With Workbooks("Book1.xls").Sheets("Sheet1")
    Range("GLB_rngToCopy").PasteSpecial xlPasteAll 'might need a . before Range
    End With
End Sub
 
Last edited:
Upvote 0
Thank you Arcticwarrio,
Actually, my GLB_rngToCopy is declared as a range.
When I change the code to
Code:
 GLB_rngToCopy.Copy
GLB_rngToPaste.PasteSpecial xlPasteAll
I get an error message saying that can't copy a range.
How could that happen?

Best regards,
lolo
Code:
Sub Paste_Script()
Workbooks.Open Filename:= _
        "C:\Stationary\Book1.xls", UpdateLinks _
        :=0
    With Workbooks("Book1.xls").Sheets("Sheet1")
    Range("GLB_rngToCopy").PasteSpecial xlPasteAll
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top