I am writing a macro that needs to look up data in a different workbook in the first sheet with a particular name. I need to copy all the data from the sheet into a select worksheet in a select workbook.
I have the following code so far.
Sub CopyCells(smallname As String, sheetname As String, LocoName As String, cells As Range, Bookinto As String, Sheetinto As String)
Workbooks.Open Filename:=LocoName
Workbooks(smallname).Activate
Worksheets(sheetname).Activate
Range("A1:Z1000").Select
ActiveSheet.Copy
Workbooks(Bookinto).Activate 'activate book
Worksheets(Sheetinto).Activate
Range("A1").Select
ActiveSheet.Paste
Workbooks(smallname).Close
End Sub
It works fine with debugging however when I try to copy the information from the files it does not copy but makes a new version of it called Book3. then it closes the original. this is fine but not really useful...
I am sure i am making a silly mistake can anyone find it?
Bookmarks