+ Reply to Thread
Results 1 to 4 of 4

delete based on criteria

Hybrid View

numbersdntlie delete based on criteria 03-25-2011, 09:34 AM
pike re: delete based on criteria 03-25-2011, 09:23 PM
numbersdntlie re: delete based on criteria 03-28-2011, 09:20 AM
royUK Re: delete based on criteria 03-28-2011, 09:53 AM
  1. #1
    Registered User
    Join Date
    07-02-2010
    Location
    Washington
    MS-Off Ver
    Excel 2003
    Posts
    20

    delete based on criteria

    Hi all-

    I have a very large excel file with 2900 rows and 25 columns. I would like an if function or macro that will compare what is in column A with column B and delete the entire row if the criteria doesnt match. For Example : items in Column A that appear more than once (ex.MAR) but has conflicting statuses is to have the rows with the status of Pending to be deleted. If there is no conflicting rows for column A item I would like it to stay. I would like the whole entire row up to column Z to be deleted for each time the macro deletes. thanks for your help.


    See attached for sample data.
    Attached Files Attached Files

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    re: delete based on criteria

    Hi numbersdntlie

    Try this loop
    Option Explicit
    Sub ntest()
        Dim xRow As Long
    Application.ScreenUpdating = False
    With Worksheets("Sheet1")
        xRow = .Cells(Rows.Count, 1).End(xlUp).Row
        For xRow = .Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
            If Trim(Cells(xRow, 1).Value) = Trim(.Cells(xRow - 1, 1).Value) And Trim(.Cells(xRow - 1, 2).Value) = "PENDING" Then
                .Cells(xRow - 1, 1).EntireRow.Delete xlShiftUp
            End If
        Next
    End With
    Application.ScreenUpdating = True
    End Sub
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    07-02-2010
    Location
    Washington
    MS-Off Ver
    Excel 2003
    Posts
    20

    re: delete based on criteria

    Thank you very much, that's works. SOLVED

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: delete based on criteria

    If you are satisfied with the solution(s) provided, please mark your thread as Solved. Also, please don't use VBA, macro in your Thread Titles. We know that as you've posted in the programming Forum & using them makes the search engine less efficient

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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