Copy named range to another Workbook

girapas

Board Regular
Joined
Apr 20, 2004
Messages
150
The workbook MyBook1 has a sheet, say DataSheet1, where there is a dynamic range, with the Name "FullNames", that refers to: OFFSET(Datasheet!$C$1;1;0;COUNTA(DataSheet!$C:$C)-1;1).
Before closing MyBook1, I want to open another workbook, say MyBook2, and copy the "FullNames" to the sheet Datasheet2. I've tried the following code but it doesn't work. Any help?

Code:
sub CopyNamesList()
    Dim range2copy As Range
    Worksheets("DataSheet1").Select
    range2copy = ActiveWorkbook.Names("FullNames")
    range2copy.Select
    Selection.Copy
    Workbooks.Open FileName:="MyBook2.xls"
    Worksheets("DataSheet2").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWorkbook.Close
end sub
 
Last edited by a moderator:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try this:

Code:
Sub CopyNamesList()
Dim range2copy As Range
    Worksheets("DataSheet1").Select
    Range("FullNames").Copy
    Workbooks.Open Filename:="MyBook2.xls"
    Worksheets("DataSheet2").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWorkbook.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,742
Messages
6,126,601
Members
449,320
Latest member
Antonino90

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