+ Reply to Thread
Results 1 to 2 of 2

Macro to delete rows based on two different criteria matching

  1. #1
    Registered User
    Join Date
    05-28-2014
    Posts
    1

    Macro to delete rows based on two different criteria matching

    Hello,

    I need to update the code from the below macro to use 2 sets of criteria opposed to one. Currently it looks at the values in column k, finds off setting values and clears them off my sheet. I need to add in code to look at the values in column L and if it finds a match in column L and off setting values in column K delete them off the rec.



    Sub ShowUnmatched()

    Dim Amount As Variant
    Dim Cell As Range
    Dim Data As Variant
    'Dim Description As Variant
    Dim Found As Range
    Dim InvAmount As Variant
    Dim Rng As Range
    Dim RngEnd As Range
    Dim Wks As Worksheet

    Set Wks = Worksheets("Rec")

    Set Rng = Wks.Range("K9")
    Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
    If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = Wks.Range(Rng, RngEnd)

    Application.ScreenUpdating = False

    For Each Cell In Rng
    Amount = Cell.Value
    If Amount <> "" Then
    InvAmount = Amount * -1
    Set Found = Rng.Find(InvAmount, , xlValues, xlWhole, xlByRows, xlNext, False)
    If Not Found Is Nothing Then
    If Found.Offset(0, 1) = Cell.Offset(0, 1) Then
    Cell.EntireRow.ClearContents
    Found.EntireRow.ClearContents
    End If
    End If
    End If
    Next Cell

    For r = Rng.Rows.Count To 1 Step -1
    If Rng.Item(r, 1) = "" Then Rng.Rows(r).EntireRow.Delete
    Next r


    Application.ActiveWindow.ScrollRow = 2

    Application.ScreenUpdating = True

    End Sub


    Any help would be appreciated

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,529

    Re: Macro to delete rows based on two different criteria matching

    Please start with reading the forum rules (all of them)
    #3 pertains to your post #1.
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). The result will appear like this in the post window:

+ 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 based on multiple criteria
    By Andrew E Smith in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-12-2014, 12:17 PM
  2. Macro to delete rows based on criteria in 2 maybe 3 fields
    By russellh79 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-31-2014, 03:46 PM
  3. macro - delete rows based on multiple criteria.
    By ChocksterNo1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-05-2013, 10:22 AM
  4. [SOLVED] Mark or Delete Rows based on Matching Multiple Criteria in another worksheet
    By clearbluez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2012, 02:38 PM
  5. How can I delete rows based on specific criteria using a macro?
    By akouleze in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2011, 02:49 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