I have a macro that pastes a number of rows from a "Template" sheet into the next blank row on the active sheet.
In column 2 of the first row is the value "variable". In Column 6 of the first row is a 3 digit number.
What I am wanting to do is increment the number in Column 6 by 1 when it is pasted. If there is no previous number on the active sheet, then it starts with 001.
As the sheet has other rows that don't contain numbers, and the rows with numbers are not at regular intervals, I am thinking the cell to increment needs to be determined in the following way (unless there is an easier logic) :
In Active Sheet, find last row in Column 2 that has value "variable". Offset Column by 4, to get to cell in Column 6.
Take active cell value and increment by 1 in the pasted rows, using the same criteria as above to determine which cell.
If there is no previous value of "variable" in Column 2 then value=001.
Here is the code I use to paste below into the next blank row.
Sub Paste_New_Product_from_Template()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Template")
Set pasteSheet = ActiveSheet
copySheet.Range("2:17").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).OFFSET(1, 0).PasteSpecial xlPasteAll
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
How could I incorporate the incrementing of numbers mentioned above?
EDIT
This is a sample of what the rows would look like on the Template sheet

And this is what the rows look like on Sheet1



5and 1. The output sheet had no data then the numbering starts from6? 2. The output sheet has data and the new data was pasted to say row 10, then the numbering starts from6from row 10 or row 1 in the new sheet?In column 2 of the first row is the value "variable".Aha. this should beIn row 2, second column is the value "variable".