VBA excel to copy formula from a sheet and paste to an array of worksheets. As an example, I want to copy data from worksheet Data!C4:CX204 and paste to worksheets Test1:Test50. The Worksheets from Test1:Test50 will be right after each other. I was thinking I can name one cell Test1 and another Test 50 and link to those cells in order to make the array more flexible.
Sub Button4_Click()
Dim WS_Count As Integer
Dim I As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
Dim Source As Range
Set Source = ThisWorkbook.Worksheets(1).Range("C10")
' Begin the loop.
For I = 1 To WS_Count
ThisWorkbook.worksheets(i).Select ' just select the sheet
Source.Copy Range("C11:C300").Select
ActiveSheet.Paste
Next I
End Sub
Based on the code you posted, you probably want something like this:
Sub Button4_Click()
Dim src As Range, sel As Range
Dim i as long
Set sel = Selection
Set src = ActiveWorkbook.Sheets("Data").Range("C10")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For i = 1 to 50
src.Copy ActiveWorkbook.Sheets("Test" & i).Range("C11:C300")
Next i
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.Goto sel, False
End Sub