Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Here is a slightly modified version of your code which should take care of the error you were getting (see comments for changes made). Code: -------------------- Sub CombineFiles() Range("A1").Select MyBook = ActiveWorkbook.Name MyTargetCell = ActiveCell.Address MySource = Application.GetOpenFilename Workbooks.Open Filename:=MySource Range("A1").Select Set myRange = Range(Selection, ActiveCell.SpecialCells(xlCellTypeLastCell)) '<-Solution : Take out the select here because you are setting the myRange with this line myRange.Copy Application.DisplayAlerts = False '<-- This will save you from having Excel notify you that you placed a large amount of info on the clipboard before closing the source file ActiveWorkbook.Close Application.DisplayAlerts = True Workbooks(MyBook).Activate Range(MyTargetCell).Select ActiveSheet.Paste ActiveWorkbook.Save 'SaveAs MySource <-- this is saving the Activeworkbook as the Source workbook (I don't think that is what you want to do?) End Sub -------------------- HTH -- bhofsetz ------------------------------------------------------------------------ bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807 View this thread: http://www.excelforum.com/showthread...hreadid=384599 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Paste Link not copying hyperlinks | Excel Discussion (Misc queries) | |||
Copy, paste without file name referenced after paste | Excel Discussion (Misc queries) | |||
how to repeat a paste of cells without copying again | Excel Discussion (Misc queries) | |||
Copying of cell text from one file to paste as cell comments in a 2nd file | Excel Programming | |||
Selecting ranges to copying and Paste | Excel Programming |