+ Reply to Thread
Results 1 to 6 of 6

Delete rows based on multiple criteria using an input box

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Willoughby, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    8

    Delete rows based on multiple criteria using an input box

    Hello,

    I'm new to the forum and using VBA. I would like some assistance in writing a macro that would delete a row based on multiple criteria that I would insert into an input box or pop-up. The criteria could be plain text, numeric, or alphanumeric configurations. Any assistance would be much appreciated. Attached is an example of the spreadsheet with the criteria that needs removed highlighted.

    The criteria is this:

    Keep: stock location 1291
    Keep: cost code S2012

    Delete all others
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Delete rows based on multiple criteria using an input box

    SteveGlaetti,

    What is your criteria for keeping or deleting? In your example you show what you want to be deleted, but how to determine this. What do you look at? Is there some other info that tells you to delete?
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    Willoughby, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Delete rows based on multiple criteria using an input box

    Charles,

    Thanks for the reply. I guess what I'm looking for is the option through an input box to choose what rows I would like to keep or sort based on certain criteria. In the attached sheet I want to be able to choose all of the rows that have EP3981,1291,S2007 and EP3981,1287,S2007 but the flexibility to choose up to 5 configurations with 1-5 fields each.

    Thanks
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Delete rows based on multiple criteria using an input box

    Hi,

    I placed a button in this copy. When you click it it should display a userform. You will be able to select 1 or more Items to delete.
    It looks at column B for the Items. However when I looked at your example, it seems you are wanting to remove "Duplicates". If thats the case then you will need a different code.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-01-2012
    Location
    Willoughby, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Delete rows based on multiple criteria using an input box

    Charles,

    The situation that I have is that the fields I may want to keep can be anywhere from A-Z in the columns. In one case I may want to keep the specific criteria in columns A,B,H,K or in another I may want to keep B,D,J,K. This will change depending on the report I place in the sheet. The criteria could be one criteria or a group of criteria. I hope this explains a little more I appologize for the confusion I'm just not sure how to explain it. In the attached example I would like to keep all of the rows that have the following combinations.

    a,b,c

    b,b,a

    a,a,b
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Delete rows based on multiple criteria using an input box

    Steve,

    Sorry for the delay. In what you are trying to do I do not have an answer, because the criteria keeps changing. In one example you say the criteria is in column A,B,H and K. Then the criteria may changes. This would be difficult to code because of the "Unknown" criteria. Perhaps another member with more knowledge can come up with an answer. The only thing I can think of is you know were the data is before hand you can have a code that will prompt you for the required range and then load the listbox so you can make your selection for deletion.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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