+ Reply to Thread
Results 1 to 8 of 8

Delete rows if column A matches number and meets condition in another column

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    9

    Delete rows if column A matches number and meets condition in another column

    Good evening all,

    I have a macro which currently auto filters and copies to another sheet but the problem I have is that I have orders on 2 or more rows. If one line does not meet a condition in a different column (potentially more than 2 columns) I need it to delete the entire order.

    I have attached a little sample sheet, column A has an order number but for example if the condition in column K was to delete any row containing "Digital Print - Glass" is it possible to then match the order numbers and delete both rows?

    I hope my babbling makes sense but I just wondered if it was possible

    Any help is much appreciated this is a little advanced for me
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Delete rows if column A matches number and meets condition in another column

    Add a helper column, with a formula something like:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Filter on that column, delete rows as necessary, delete helper column.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Delete rows if column A matches number and meets condition in another column

    Hi Olly

    Thanks for the quick reply!

    It works well and I have tested it changing the condition but can't seem to get it using multiple conditions in column K.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Delete rows if column A matches number and meets condition in another column

    What do you mean, multiple conditions? Are you saying you need to delete all rows containing order numbers where those order numbers have one of several values in column K - so, for example, delete all orders which have either "Digital Print - Glass" and / or "Digital Print - DCT" in column K?

    If so - you can use a similar approach to my first post, just tweak the formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It should be easy enough to create a formula like that using VBA, based on the number of conditions you want to match.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Delete rows if column A matches number and meets condition in another column

    Here you go: put your conditions into the array, then this adds the helper column with that formula.

    Please Login or Register  to view this content.
    You can then do your filtering / copying / whatever, then safely delete the helper column.

  6. #6
    Registered User
    Join Date
    09-12-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Delete rows if column A matches number and meets condition in another column

    Sorry I meant to say it should delete order numbers and where they have several values from K ("Digital Print - Glass" and / or "Digital Print - DCT" and / or "Digital Print - Ceramic") The amended formula works good thanks I'll try to add something simular to the end of my vba

    Cheers for the help

  7. #7
    Registered User
    Join Date
    09-12-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Delete rows if column A matches number and meets condition in another column

    Top man! That's worked perfectly!

    Thank you for your help its much appreciated

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Delete rows if column A matches number and meets condition in another column

    Glad it helped. If your question is answered, please mark this thread 'Solved'

+ 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. help need to copy and delete rows if condition meets
    By punar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 03:38 AM
  2. Delete rows in separate tabs if string in column A matches
    By bonsaitrees in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-14-2012, 03:43 PM
  3. [SOLVED] Delete whole row if column F meets a condition untill last row of data
    By andywsw in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-12-2012, 04:29 AM
  4. Replies: 1
    Last Post: 07-12-2007, 04:17 PM
  5. Count the number of rows where more than one column meets set crit
    By BarrieVoice in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-14-2006, 02:30 PM

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