Hello,
I'm currently using the following code to copy and paste a range of cells from one workbook to another. Everything is working as intended but next quarter, I need to run this macro again but have the quarter 2 results pasted on the next empty row. If I was to run it again the way it's currently set up, it would obviously overwrite quarter 1 results. How can I change my macro so that it doesn't overwrite what's already in there but rather paste starting on next empty row? Thanks!
Sub CommandButton1_Click()
Dim strfilename As String
For Each wb In Application.Workbooks
If wb.Name <> ActiveWorkbook.Name Then
strfilename = wb.Name
Debug.Print strfilename
End If
Next
Application.ScreenUpdating = False
Windows(strfilename).Activate
Sheets("Non Salary Spending").Select
Range("A13:N400").Select
Selection.Copy
Windows("PivotTool.xlsm").Activate
Sheets("NonSalaryByPeriod").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
I'm currently using the following code to copy and paste a range of cells from one workbook to another. Everything is working as intended but next quarter, I need to run this macro again but have the quarter 2 results pasted on the next empty row. If I was to run it again the way it's currently set up, it would obviously overwrite quarter 1 results. How can I change my macro so that it doesn't overwrite what's already in there but rather paste starting on next empty row? Thanks!
Sub CommandButton1_Click()
Dim strfilename As String
For Each wb In Application.Workbooks
If wb.Name <> ActiveWorkbook.Name Then
strfilename = wb.Name
Debug.Print strfilename
End If
Next
Application.ScreenUpdating = False
Windows(strfilename).Activate
Sheets("Non Salary Spending").Select
Range("A13:N400").Select
Selection.Copy
Windows("PivotTool.xlsm").Activate
Sheets("NonSalaryByPeriod").Select
Range("B2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False