I am fairly new to VBA and I am trying to write a macro that copies a row based on if a cell meets a criteria. I believe I found a macro that can accomplish that portion, the 2nd part is where I am struggling to find a solution.
If you can refer to the image I have provided, my macro is to look into column 3 of the first spreadsheet, "Original" and copy & paste the row into a new spreadsheet, "Apples", when it sees Apples.
What I am trying to also include is the Count total row that proceeds the copied and pasted row to also copy the row and paste into spreadsheet "Apples"
Spreadsheet Original
Spreadsheet Apples
Desired Spreadsheet Apples
Macro I am using to get my current results.
Sub Macro1()
a = Worksheets("Original").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("Original").Cells(i, 3).Value = "Apples" Then
Worksheets("Original").Rows(i).Copy
Worksheets("Apples").Activate
b = Worksheets("Apples").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Apples").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Original").Activate
End If
Next
Application.CutCopyMode = False
ThisWorkbook.Worksheets("Original").Cells(1, 1).Select
End Sub