I am trying to code a loop that takes each row from a page of the main worksheet, and places each in a corresponding worksheet. For instance, row A1:A10 on worksheet one would be copied and placed on A1:A10 on worksheet 2. And on worksheet 3, the A1:A10 Values would be from worksheet one values A2:A10. But my problem is, I can't find the right syntax to loop through my loop using the Range and Cell functions.
My Code:
'i is set to the first worksheet I am writting to
'wsCount is set to the last worksheet I want to write to
For i = 2 To wsCount
Worksheets(i).Activate
'This code shifts old information down so the most recent is always on top
Worksheets(i).Range("A3:L262").Select
Selection.Copy
Worksheets(i).Range("A4").Select
ActiveSheet.Paste
'This sets the first cell in the row to be the current date
Worksheets(i).Range("A3").Value = Format(Now, "ddd, d mmmm yyyy")
'This is my problem, I am trying to set the range
'B3:L12 to the corresponding row in the main worksheet
Worksheets(i).Range(Cells(3, 2), Cells(3, 12)).Value = Worksheets(1).Range(Cells(x, 2), Cells(x, 12)).Value
Worksheets(i).Range("A1").Select
x = x + 1
Next i
This error throws "Run-time error '1004': Application-defined or object-defined error"
I feel like my syntax is correct, because when I run:
Worksheets(1).Range(Cells(10, 2), Cells(10, 12)).Value = "Test"
It runs fine, but only when the worksheet(1) is selected. So I know that I need to select the first worksheet to pull information from it, to the other worksheets or something like that. What am I missing? Does it have something to do with my "Worksheets(i).Activate" statement at the beginning of the loop? I am new to VBA and am not sure about the permissions for Excel VBA macros.