T
tim64
I have this code that is suppose to open the file copy all its content
and then paste it in the file the code is in. But the code has an erro
(see below)
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(xlLastCell)).Selec
<--------------------------------- error: type mismatch
MyRange.Copy
ActiveWorkbook.Close
Workbooks(MyBook).Activate
Range(MyTargetCell).Select
ActiveSheet.Paste
ActiveWorkbook.SaveAs MySource
End Su
and then paste it in the file the code is in. But the code has an erro
(see below)
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(xlLastCell)).Selec
<--------------------------------- error: type mismatch
MyRange.Copy
ActiveWorkbook.Close
Workbooks(MyBook).Activate
Range(MyTargetCell).Select
ActiveSheet.Paste
ActiveWorkbook.SaveAs MySource
End Su