My aim is to write a macro which will copy monthly data from the source, which is a workbook with data in multiple sheets, into my historic workbook which has the same multiple sheets but obviously the previous historic data as well.
So far I have managed to pull together some code which allow me to select the file, copy the range which will paste in the blank cell below the current data.
What I need is to write code so this happens to all sheets at the same time. Sheet1 source workbook to Sheet1 in the historic workbook and so on... Sheet2 to Sheet2...... up to Sheet9 to Sheet9.
I am getting confused with how to Dimension the different sheets and would appreciate some help.
Do I need to dimension each sheet and repeat the code for every copy paste i want to do?
So far I have managed to pull together some code which allow me to select the file, copy the range which will paste in the blank cell below the current data.
Code:
Sub copy()
Dim wbSource As Workbook
Dim wsDest As Worksheet
Dim SourceFileName As String
SourceFileName = Application.GetOpenFilename(FileFilter:="Excel Files (*xls),*xls", Title:="Please select a file")
Set wsDest = ThisWorkbook.Worksheets("Sheet1")
Application.ScreenUpdating = False
Set wbSource = Workbooks.Open(Filename:=SourceFileName, ReadOnly:=True)
wbSource.Sheets("Sheet1").Range("A1:C6").copy
wsDest.Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
wsDest.Range("A1").PasteSpecial xlPasteFormats
wbSource.Close False
With Application
.CutCopyMode = False
.ScreenUpdating = True
End With
End Sub
What I need is to write code so this happens to all sheets at the same time. Sheet1 source workbook to Sheet1 in the historic workbook and so on... Sheet2 to Sheet2...... up to Sheet9 to Sheet9.
I am getting confused with how to Dimension the different sheets and would appreciate some help.
Do I need to dimension each sheet and repeat the code for every copy paste i want to do?