I am trying to loop through specific sheets in Excel and have the formula in A1 paste through the last row of data. The code below works for the first sheet that is listed, however, it does not carry over to subsequent worksheets.
Sub Refresh_ActivesheetB36()
Dim lastrow As Long
Dim MyArray As Variant
Dim i As Integer
Application.ScreenUpdating = False
Sheets("GroupInfo").Select
Range("B36").Select
Selection.Formula = "=COUNTIF('TAX INFO'!E15:E1499,"">0"")"
MyArray = Array("DATA Member", "DATA Sch A")
With Worksheets(MyArray)
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
End With
On Error Resume Next
For i = LBound(MyArray) To UBound(MyArray)
With Worksheets(MyArray(i))
Range("A1").Select
Range("A1:A" & lastrow).PasteSpecial
End With
Next i
On Error GoTo 0
Application.ScreenUpdating = True
Worksheets("GroupInfo").Select
End Sub