+ Reply to Thread
Results 1 to 9 of 9

If Function Based On Criteria to Delete

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

    If Function Based On Criteria to Delete

    Hi All,

    I have a very large excel file with 2900 rows and 25 columns. I would like an if function or method that will compare what in column A with column B and delete the entire row it if the criteria doesnt match. For Example :

    Column A Column B

    FHIT HOT
    FHIT COLD
    FHIT COLD
    RFKP COLD
    RFKP HOT
    DUGH HOT
    DEPS COLD
    DEPS HOT

    What i would like to happen is have the entire 25 columns in each row deleted: if there are 2 or more columns A's with the same info (FHIT-for example) I would like the row or rows with "cold" to be deleted. If there isn't 2 or more matching column A i would like the row to not be deleted. Any help will be greatly appreciated thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: If Function Based On Criteria to Delete

    Please Login or Register  to view this content.

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

    Re: If Function Based On Criteria to Delete

    Hi, thanks for the macro. That seems to work for the first 3 rows. How do i get that process ran for all 2900 rows?

    Thanks for the help

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: If Function Based On Criteria to Delete

    see attachment, run macro "test" (tested on 2900 rows and 29 columns, takes 6.28 sec). Check result on sheet "2". The code processes rows from 1 to 2900 only
    Attached Files Attached Files
    Last edited by watersev; 02-04-2011 at 10:11 PM.

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

    Re: If Function Based On Criteria to Delete

    Thanks for the assistance but the macro could not be ran.

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: If Function Based On Criteria to Delete

    Make sure the following reference is on:
    1. [Alt+F11] - open Visual Basic window
    2. Tools - References - find and tick "Microsoft Activex Data Objects 2.0 Library"
    3. Run macro "test"

  7. #7
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: If Function Based On Criteria to Delete

    Hello numbersdntlie:
    The macro I provided should work on any number of rows in fact I've tested it on 500 rows with no problem ... could you provide a sample sheet so I can see what's going on ?
    Last edited by nimrod; 02-05-2011 at 07:33 PM.

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

    Re: If Function Based On Criteria to Delete

    Hi nimrod-

    Thanks for your help on this. See attached file. As you can see in the "Ex Data" column there are some rows with matching info ( i sorted data to make more visable) but has different statuses in column B. What I wanted to happen which your macro did but not on the whole sheet is to have the 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 a 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.
    Attached Files Attached Files
    Last edited by numbersdntlie; 02-06-2011 at 06:18 AM.

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

    Re: If Function Based On Criteria to Delete

    Bump no response

+ 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