How to prevent copying names when copying ranges

KDY

New Member
Joined
Oct 4, 2011
Messages
9
I am copying relatively large amounts of data from a sheet in one workbook to a sheet in another workbook using vba. To speed up the process I am using a method supposed to be faster (data is not copied via the clipboard):

Set RangeWithData = WS_WithData.Range("A1:X1000")
Set TargetRange = WS_Target.Range("C5:Z1004")

RangeWithData.copy Destination:=TargetRange

However, there is a unfortunate side effect: Named ranges from the source workbook are copied to the target workbook with ref to the source workbook as well.:mad:

I fail to see the logic:confused:, and I would like to avoid this. Any ideas?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
To speed up the process I am using a method supposed to be faster (data is not copied via the clipboard):

RangeWithData.copy Destination:=TargetRange

Why would this not go to the clipboard? You use the normal Copy command?

You're talking about speeding up code execution. Speeding up in a real way, would be only transferring values, rather than copying entire cells (formatting, ... included):

Code:
WS_Target.Range("C5:Z1004") = WS_WithData.Range("A1:X1000").Value
 
Upvote 0
Thanks for responding wigi,

As I said: "supposed". Apparently I have been mislead. Just a poor weekend programmer, I am.

I will try to follow your suggestion.

Still bugs me, though, the logic in copying named ranges between the workbooks as a side product of a range copy. Any explanation/justification for this vba behaviour.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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