+ Reply to Thread
Results 1 to 5 of 5

If - And multiple rows to be kept or deleted based on multiple columns? (Example)

  1. #1
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    If - And multiple rows to be kept or deleted based on multiple columns? (Example)

    Hi all,

    I would like to ask your help with a VBA code, as I am still a bit new on this field. I attached an excel sheet, on Sheet 1 the table I would like to reduce, and how, on sheet 2 the outcome I would like to achieve but I have done this manually,and it is practically impossible on my real data set, so I started to write a vba code to format it.

    On the example, there are First Names, Last Names, Fruits and Basket sizes. So if First Names and Last Names and the Fruits match in several rows, I would like to delete the dupli-tripli-cate rows - and keep only 1, and the 1 that is kept, should be the one that has 05 basket in the basket size column, if there is no 05 basket then it doesn't matter which one is kept.

    If in several (unknown amount) rows, in column A B and C the values are the same, then delete these rows until only 1 is left, if in D the value is "05*" then keep that, as the 1 row that is left.

    I was thinking maybe do it with loops, but I am really not sure, and don't exactly know how. Anyone could help please?

    Thank you!
    Attached Files Attached Files
    Last edited by LIL2606; 02-06-2019 at 06:34 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: If - And multiple rows to be kept or deleted based on multiple columns? (Example)

    Nothing attached!
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: If - And multiple rows to be kept or deleted based on multiple columns? (Example)

    Sorry I edited it, it is attached now. I had to log back in in the middle of describing, and it got lost in the log ins by the looks of it.

  4. #4
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: If - And multiple rows to be kept or deleted based on multiple columns? (Example)

    So I think it could would begin with a loop.. integer k

    For k = count the rows if the - do while - same values are in A B and C columns in several rows...
    then... maybe... select the rows, and if in D column neither values are "05*" then delete k-1 rows from this selection?

    but I'm not sure.. I'm thinking it needs another loop above k, that would help with the selection? like l as integer, and l to step down the rows, and the selection would be k-l rows?

    Makes sense or inspires anyone, by any chance?

  5. #5
    Forum Contributor
    Join Date
    08-29-2017
    Location
    London England
    MS-Off Ver
    2016
    Posts
    194

    Re: If - And multiple rows to be kept or deleted based on multiple columns? (Example)

    If the D column values don't matter? Does it make it possible?

+ 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. Replies: 1
    Last Post: 02-09-2017, 05:55 PM
  2. Combining Rows based on Multiple Columns
    By wlavallee in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-16-2016, 12:24 PM
  3. Replies: 6
    Last Post: 05-30-2016, 01:59 PM
  4. Search Multiple Columns and Rows - Show results in Multiple columns and rows
    By heykeighley in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-12-2015, 10:16 AM
  5. [SOLVED] Multiple worksheet to be deleted based on the values in cells.
    By muralidaran in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2015, 06:39 AM
  6. Average multiple rows based on 2 columns
    By beaner in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-19-2011, 09:18 PM
  7. Replies: 1
    Last Post: 05-18-2009, 11:21 AM

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