+ Reply to Thread
Results 1 to 2 of 2

Trying to add a second condition to a macro that will delete rows

  1. #1
    Registered User
    Join Date
    02-11-2015
    Location
    Vancouver
    MS-Off Ver
    2010
    Posts
    1

    Trying to add a second condition to a macro that will delete rows

    Hello,

    I am a newb and have been searching on how to delete rows based on two conditions. The first sub works but I cant combine them, the two conditions are:
    1- Delete all rows that have dates less than "1/1/15" (found in Column C)
    2- Delete all rows that are not equal to "LOS Loan Origination System" (found in Column J)

    Any advice would be appreciated.

    Sub deleteFiltered()
    Dim rng As Range

    With Worksheets("Report Work Orders by group, da")
    If Not .AutoFilterMode Then
    Columns("C:C").Select
    Selection.AutoFilter
    ("Report Work Orders by group, da").Range("$C$1:$C$2250").AutoFilter Field:=1,Criteria1:= _
    "<1/1/2015", Operator:=xlAnd
    End If
    With .AutoFilter.Range
    On Error GoTo exithandler
    Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
    .SpecialCells(xlCellTypeVisible)

    End With
    End With
    rng.EntireRow.Delete
    Columns("c:c").Select
    Selection.AutoFilter
    exithandler:
    End Sub


    Here is the second one

    With Worksheets("Report Work Orders by group, da")
    If Not .AutoFilterMode Then
    Columns("J:J").Select
    Selection.AutoFilter
    ("Report Work Orders by group, da").Range("$J$1:$J$2250").AutoFilter Field:=1,Criteria1:= _
    "<>LOS Loan Origination System", Operator:=xlAnd

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Trying to add a second condition to a macro that will delete rows

    You could try something similar to this:

    Please Login or Register  to view this content.
    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to delete rows ONLY if condition is met
    By lealea1982 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2013, 06:03 AM
  2. Macro to delete all rows based on one condition
    By vemix in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2012, 05:24 AM
  3. Macro to delete rows if certain condition is met
    By mjali001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2011, 05:20 AM
  4. macro to delete rows with a condition
    By Foxcan in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-29-2009, 01:49 PM
  5. Macro to Delete Specific Rows (Condition)
    By leviathan86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2009, 06:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1