Me again... I've amended the code above to suit my purpose and it's working fine.
I now want to run the same 'code' for multiple sheets. I am copying the same columns from each sheet (A, B, Y, Z, AA, AB, AC, AD, AE) based on the Z value='Active'
There are 7 sheets in total ("Prep", "Year 1", "Year 2", "Year 3", "Year 4", "Year 5", "Year 6"). And I want them to copy into the sheet "2018 Active" into columns A, B, C, D, E, F, G, H, I.
I tried copying the same code underneath and changing "Year 1" to "Year 2" but it only brought back the year 1 data.
I haven't worked with this type of code before and am not sure of what most of it means to be able to problem solve.
I've pasted the amended code here...
Sub Gen_Active()
Dim lastRow As Long
Dim myRow As Long
Dim myCopyRow As Long
' Set initial row to copy to as 4
myCopyRow = 4
' Find last row with data in column A on sheet 1
lastRow = Sheets("Year 1").Cells(Rows.Count, "Z").End(xlUp).Row
Application.ScreenUpdating = False
' Loop through all rows in Year 1
For myRow = 3 To lastRow
If Sheets("Year 1").Cells(myRow, "Z") = "Active" Then
Sheets("2018 Active").Cells(myCopyRow, "A") = Sheets("Year 1").Cells(myRow, "A")
Sheets("2018 Active").Cells(myCopyRow, "B") = Sheets("Year 1").Cells(myRow, "B")
Sheets("2018 Active").Cells(myCopyRow, "Y") = Sheets("Year 1").Cells(myRow, "C")
Sheets("2018 Active").Cells(myCopyRow, "Z") = Sheets("Year 1").Cells(myRow, "D")
Sheets("2018 Active").Cells(myCopyRow, "AA") = Sheets("Year 1").Cells(myRow, "E")
Sheets("2018 Active").Cells(myCopyRow, "AB") = Sheets("Year 1").Cells(myRow, "F")
Sheets("2018 Active").Cells(myCopyRow, "AC") = Sheets("Year 1").Cells(myRow, "G")
Sheets("2018 Active").Cells(myCopyRow, "AD") = Sheets("Year 1").Cells(myRow, "H")
Sheets("2018 Active").Cells(myCopyRow, "AE") = Sheets("Year 1").Cells(myRow, "I")
' Increment row counter
myCopyRow = myCopyRow + 1
End If
Next myRow
Application.ScreenUpdating = True
End Sub