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?
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: