Trundlethegr8
New Member
- Joined
- Jan 26, 2022
- Messages
- 6
- Office Version
- 365
- 2016
- Platform
- Windows
Good morning,
This is my second post so apologies if i don't include all the required info.
I have a workbook that tracks customer expenditures. The summary worksheet lists all customers and displays the current financial data. Each customer has an indidivual worksheet that tracks the daily data for historical reference. I currently have gotten some assistance to create a macro that copies the data from the Summary sheet and pastes on the individual worksheet if column A matches a worksheet name.
I have formulas on each individual customer worksheet that calculates various differences on columns P through S. When the new data is pasted from the Summary sheet, is there a way to copy/paste the formula from the row above the new data?
Apologies again if this doesnt make sense.
Here is what i currently have.
Sub Copy_Rows_To_Sheet()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
Dim Lastrowa As Long
Dim ans As String
With Sheets("Summary")
For i = 2 To Lastrow
ans = .Cells(i, 1).Value
Lastrowa = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
.Rows(i).Copy: Sheets(ans).Rows(Lastrowa).PasteSpecial xlPasteValues, Transpose:=False
Next
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
Exit Sub
End Sub
This is my second post so apologies if i don't include all the required info.
I have a workbook that tracks customer expenditures. The summary worksheet lists all customers and displays the current financial data. Each customer has an indidivual worksheet that tracks the daily data for historical reference. I currently have gotten some assistance to create a macro that copies the data from the Summary sheet and pastes on the individual worksheet if column A matches a worksheet name.
I have formulas on each individual customer worksheet that calculates various differences on columns P through S. When the new data is pasted from the Summary sheet, is there a way to copy/paste the formula from the row above the new data?
Apologies again if this doesnt make sense.
Here is what i currently have.
Sub Copy_Rows_To_Sheet()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
Dim Lastrowa As Long
Dim ans As String
With Sheets("Summary")
For i = 2 To Lastrow
ans = .Cells(i, 1).Value
Lastrowa = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
.Rows(i).Copy: Sheets(ans).Rows(Lastrowa).PasteSpecial xlPasteValues, Transpose:=False
Next
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
Exit Sub
End Sub