0

I would like to copy and paste rows from my master sheet. I have created this VBA

Private Sub CommandButton3_Click()
    a = Worksheets("Monthly VGT Report").Cells(Rows.Count, 1).End(xlUp).Row
    
    For i = 2 To a
        If Worksheets("Monthly VGT Report").Cells(i, 2).Value = "531204" Then    
            Worksheets("Monthly VGT Report").Rows(i).Copy
            Worksheets("Store 1").Activate
            b = Worksheets("Store 1").Cells(Rows.Count, 1).End(xlUp).Row
            Worksheets("Store 1").Cells(b + 1, 1).Select
            ActiveSheet.Paste
            Worksheets("Monthly VGT Report").Activate
        End If
    Next
    
    Application.CutCopyMode = False
    
    ThisWorkbook.Worksheets("Monthly VGT Report").Cells(1, 1).Select
End Sub

This work perfectly however, is there a way I can have it copy multiple searches with just one active command button. Right now I have 6 buttons that are searching different key words. For example: If Worksheets("Monthly VGT Report").Cells(i, 2).Value = "531204" Then.

Is there way to search for the number "531204" & " 542376" within one code ? The data that I am searching for is in column B and my data started in column A. I want the whole row A1:H1 copied.

  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). Have a look in the link above your question for how to filter and copy the filtered data. It has both solutions, autofilter and using loops. – Pᴇʜ Dec 09 '20 at 09:37
  • Thank you, Ive reviewed the link and i dont really see what im looking for. I'm new to code so I don't quite understand how to incorporate additional formulas. Is there not a way to search addition cells within the formula I have ? – Elexus King Dec 09 '20 at 16:49

0 Answers0