+ Reply to Thread
Results 1 to 3 of 3

Delete rows based on the values within two columns (CustID & Location)

  1. #1
    Registered User
    Join Date
    03-22-2012
    Location
    M, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    45

    Delete rows based on the values within two columns (CustID & Location)

    I would like to exclude records for all customers (CustID) other than those who:
    1) Have at least two records with a specified Location, and
    2) Have at least one record with a location other than the specified Location.

    Please see the attached Excel file for a more clear description!

    Is it possible that this can be accomplished with some combination of Excel formulae and sorting? Or is VBA coding required?

    Thank you!

  2. #2
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Re: Delete rows based on the values within two columns (CustID & Location)

    I used helper columns to set the criteria of having a minimum of 2 Rochester Locations, and one for all others.
    There is a macro that will delete any rows marked with "x" in column A.

    You could also just filter by "x" and delete the rows manually.
    Another possibility is to not have the helper columns at all, and to put all the formulae into the macro, but it would take me quite a while to figure out the best way to write the macro for it to not be as crud as recording the formulae into the macro.

    Perhaps a more advanced member on the site will have the answer and be able to have a clean code for this.

  3. #3
    Registered User
    Join Date
    03-22-2012
    Location
    M, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Delete rows based on the values within two columns (CustID & Location)

    Thank you, ufopilot! That looks like a great start! However, within my sample worksheet, I would need to delete all records except the final six (those for CustID 2556, who meets the two criteria); and it appears that the formula does not mark all of those for deletion. Or perhaps I misunderstood your response?

+ 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. Delete unwanted rows and update count of rows based on values
    By boddulus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2015, 08:34 PM
  2. Delete rows based on 3 columns
    By nitin1309 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-27-2013, 03:32 PM
  3. Delete rows based off two columns
    By lricci in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2013, 12:37 PM
  4. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 AM
  5. Macro to delete entire rows based values in columns
    By shamade2107 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2009, 11:17 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