RUN-TIME ERROR '91'
Object variable or With block variable not set
Object variable or With block variable not set
Code:
[COLOR=#333333]Sub SummaryRow()Dim Wkb As Excel.Workbook[/COLOR]Dim ws As Worksheets
Dim ws_count As Integer
Dim i As Integer
Dim LastRow As Long
Sheet4.Range("a183:M183").Copy
Set Wkb = ThisWorkbook
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)
LastRow = Wkb.Worksheets(i).Cells(Rows.Count, 1).End(xlUp).Row
'Paste Formulas
TargetRow.PasteSpecial xlPasteFormulas
[B]ws(i).Cells(LastRow + 1, 7).FormulaR1C1 = "=SUM(R4C7:R" & LastRow & "C7)"
ws(i).Cells(LastRow + 1, 8).FormulaR1C1 = "=COUNT(R4C8:R" & LastRow & "C8)"
ws(i).Cells(LastRow + 1, 9).FormulaR1C1 = "=SUM(R4C9:R" & LastRow & "C9)"[/B]
TargetRow.PasteSpecial xlPasteFormats
Next i
[COLOR=#333333]End Sub[/COLOR]