Copy cells based on multiple criteria

kingconsto

New Member
Joined
Apr 19, 2017
Messages
32
Hello,

I am trying to get a excel formula or macro that will allow me to extract specific fields from an excel table given 2 criteria (filtering). For example, I would like to only look at data in Column B whose criteria whould be "Boats" and filter column E to only show those fields that are integers (no letters allowed). I would then copy the corresponding data from Column D and column H and paste it to another existing sheet. I can explain further if this isn't making sense.

Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I have the following but it only fits for one criteria (I have 2, the other being in cloumn E) and when the data copies, it just pastes over the last data and doesn't continue on the next row.

Code:
Sub copyrows()
     
    Dim tfCol As Range, Cell As Object
     
    Set tfCol = Sheets("D.AFS").Range("B8:B400") 'Substitute with the range which includes your True/False values
     
    For Each Cell In tfCol
         
        If IsEmpty(Cell) Then
            Exit Sub
        End If
         
        If Cell.Value = "LMA_CZK_AFS_CFH" Then
            Cell.EntireRow.Copy
            Sheets("NPV").Select 'Substitute with your
            RowCount = Cells(Cells.Rows.Count, "A").End(xlUp).Row
            Range("A" & RowCount + 1).Select
            'ActiveSheet.Range("A80").End(xlUp).Select
            'Selection.Offset(1, 0).Select
            ActiveSheet.Paste
        End If
         
    Next
     
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top