Background:
I have an array of 7 x 30 cells to loop through. For each of the 30 columns (Dim j), I am looping through rows (Dim i) 1 to see if a value is present and if so start copying the range of rows 2 through 7.
In attempting to use (e.g.):
Sheets("NAME").Range(Cells(i+1,1),Cells(i+7,1)).Copy
I am getting a 1004, Application-defined or object-defined error, that I have been able to alleviate using:
Sheets("NAME").Range("A" & i+1 & ":A" & i+7 & ").Copy
Error on line from my code:
Sheets("RM").Range(Cells(i + 6, 2), Cells(i + 13, 2)).Copy
Issue:
This has worked for items with known columns, but I am unsure how to proceed for a variable column, as well. I know that this doesn't work:
Sheets("NAME").Range(Cells(i+1,j),Cells(i+7,j)).Copy
I would need to find a way to fit this Range model without Cells to work for j, a variable column.
Question:
Is there a way to make this work using Range without using Cells?
My only guess is the following, which I believe uses incorrect syntax:
Sheets("NAME").Range(Columns(j) & i+1 & ":" & Columns(j) & i+1).Copy
Any help would be appreciated!
Edit: added the error 1004 name to this Issues section.
Cells()
as you did theRange()
:Sheets("NAME").Range(Sheets("NAME").Cells(i+1,1),Sheets("NAME").Cells(i+7,1)).Copy
– Scott Craner