I've copied a row from a spreadsheet, I then get the code to find the last row in each sheet and paste the summary row, which includes sum and count formulas, but the row number changes for each sheet.
How do I get the pasted formula to adjust to the number of rows in the sheet.
How do I get the pasted formula to adjust to the number of rows in the sheet.
Code:
Sub SummaryRow()Dim Wkb As Excel.Workbook
Dim ws As Worksheets
Dim ws_count As Integer
Dim i As Integer
Dim LastRow As Long
Dim TargetRow As Range
Sheet4.Range("a183:M183").Copy
Set Wkb = Workbooks("VBA1.xlsm")
ws_count = Wkb.Worksheets.Count
'Begin loop
For i = 4 To ws_count
Set TargetRow = Wkb.Worksheets(i).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
'Paste Formulas
TargetRow.PasteSpecial xlPasteFormulas
TargetRow.PasteSpecial xlPasteFormats
Next i
End Sub