+ Reply to Thread
Results 1 to 4 of 4

Remove rows with empty cells depending on multiple columns

  1. #1
    Registered User
    Join Date
    01-18-2022
    Location
    Lyon
    MS-Off Ver
    2007-365
    Posts
    2

    Question Remove rows with empty cells depending on multiple columns

    Hi there !

    Basically I have the following table (see sheet named "BEFORE" on attached file):

    I'm trying to merge the rows that have obvious duplicate values into unique ones by adding/replacing empty cells with information from other rows.

    For instance, here rows [ID] 1, 2 and 3 hold details about company A.
    Rows 4 and 6 hold details about company B.
    Rows 5 and 7 hold details about company C.


    I have tried the following code to merge duplicate rows into unique ones.

    Please Login or Register  to view this content.
    The issue here is I don't get the expected result : .Removeduplicates works fine when you specify 1 or 2 columns in the Array() subproperty but does not work properly when you specify too many columns.

    Therefore I came up with the following method for which I need help at the coding:
    1. Sort rows based on company name (column B)
    2. If 2 or more rows have duplicate values based on company name (column B), then add values from other rows to the first row according to the following rule : Replace [EmptyCell] with [CellWithValue]
    3. Apply this rule to all columns
    4. Delete duplicate rows using .Removeduplicates

    The expected result should look like the sheet named "AFTER".

    Any ideas?

    P.S: I had a table prepared in HTML to make it easier but forum policies forbid me from using it
    Attached Files Attached Files

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Remove rows with empty cells depending on multiple columns

    Here's some code that might work for you:

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    01-18-2022
    Location
    Lyon
    MS-Off Ver
    2007-365
    Posts
    2

    Re: Remove rows with empty cells depending on multiple columns

    It works! Thank you WBD

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Remove rows with empty cells depending on multiple columns

    Here is a different option just for grins:

    Please Login or Register  to view this content.

+ 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. [SOLVED] Need formula to combine values in two columns, remove empty cells, & alphabetize.
    By Big.Moe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-22-2017, 06:33 AM
  2. Macro VBA - Remove empty rows and columns with total deleted in msg
    By SmurofNeves in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2015, 06:17 AM
  3. Combining multiple rows from 2 columns into sorted columns depending on 1st columns value
    By Dexamphetamine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-11-2013, 10:00 AM
  4. [SOLVED] Remove Empty Rows ,Columns & Sort
    By johncena in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-18-2013, 03:40 AM
  5. [SOLVED] Remove rows with empty cells in column 1
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-08-2012, 07:05 AM
  6. Help remove the empty columns or rows
    By SimonLee in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2011, 11:20 PM
  7. Remove rows if certain cells are empty
    By VBisgreat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2009, 04:21 PM

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