Copy Row to Seperate Sheet Based on Multiple Criteria

ExcelEndeavor

New Member
Joined
Oct 13, 2020
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
I have a report that I need to automaticallty filter out all of the rows that are not affected by the multiple criteria below. On the screenshot below, I paste the data from a report that I pull daily. To help visualize it, I manually went through and selected those items that need to be addressed (in red). I want to eliminate the rows that do not have issues, so we can focus only on the problem files. Not sure if I need a formula or VBA.

I want to only show the rows with the following criteria:

Column C (HCLTV)
>80.001 then Column D cannot be "AVM"
>90,001 (Anything over 90%)

Column B (Loan Amount)
>400,001 then Column D cannot be "AVM"
>500,001 then Column D cannot be "AVM", "Exterior", "Hybrid Exterior", or "Hybrid Interior"


As you can see on my attachment, some rows might be affected my more than one of the criteria, thus multiple red cells in a row.

Thank you in advance for your help.
 

Attachments

  • Valuation.jpg
    Valuation.jpg
    73.9 KB · Views: 11

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi ExcelEndeavor,

Try this:

VBA Code:
Option Explicit
Sub Macro1()

    Dim wsFrom As Worksheet, wsTo As Worksheet
    Dim lngRowTo As Long, lngRow As Long, lngPasteRow As Long
    Dim blnInvestigate As Boolean
    
    Application.ScreenUpdating = False
    
    Set wsFrom = ThisWorkbook.Sheets("Sheet1") '<-Sheet name containing raw data. Change to suit.
    Set wsTo = ThisWorkbook.Sheets("Sheet2") '<-Sheet name for items to be investigated. Change to suit.
    
    lngRowTo = wsFrom.Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    
    For lngRow = 2 To lngRowTo
        If Round(wsFrom.Range("C" & lngRow), 3) > 80.001 And wsFrom.Range("D" & lngRow) = "AVM" Then
            blnInvestigate = True
        ElseIf Round(wsFrom.Range("C" & lngRow), 3) > 90.001 Then
            blnInvestigate = True
        ElseIf Round(wsFrom.Range("B" & lngRow), 0) > 400001 And wsFrom.Range("D" & lngRow) = "AVM" Then
            blnInvestigate = True
        ElseIf Round(wsFrom.Range("B" & lngRow), 0) > 500001 Then
            If wsFrom.Range("D" & lngRow) = "AVM" Or wsFrom.Range("D" & lngRow) = "Exterior" Or wsFrom.Range("D" & lngRow) = "Hybrid Exterior" Or wsFrom.Range("D" & lngRow) = "Hybrid Interior" Then
                blnInvestigate = True
            End If
        End If
        If blnInvestigate = True Then
            If lngPasteRow = 0 Then
                lngPasteRow = 2
            Else
                lngPasteRow = wsTo.Range("A:D").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
            End If
            wsFrom.Range("A" & lngRow & ":D" & lngRow).Copy Destination:=wsTo.Range("A" & lngPasteRow)
        End If
        blnInvestigate = False
    Next lngRow
    
    With Application
        .CutCopyMode = False
        .ScreenUpdating = True
    End With
    
End Sub

Note for Ahlers none of the exception criteria are met so it should not be considered.

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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