+ Reply to Thread
Results 1 to 3 of 3

VBA+Delete duplicate rows ignoring certain columns

  1. #1
    Forum Contributor
    Join Date
    06-28-2018
    Location
    New York
    MS-Off Ver
    MS Office 2010
    Posts
    184

    VBA+Delete duplicate rows ignoring certain columns

    Hi all,

    I have a file that contains data from columns B3 to V (rows will be dynamic). I am looking to delete duplicate rows of data in my set (if any exists otherwise do nothing), however columns G&H can be disregarded. Meaning whether the data in G&H is duplicated or not is irrelevant. A sample file has been provided. Thank you in advance for any assistance!

    Note there are duplicate columns in the set as well, which can/should be disregarded at this time. Thanks again.


    The below actually works but I'm not sure how to modify it for my range while ignoring columns G&H.

    Please Login or Register  to view this content.

    Perhaps like this, but I would like the experts to weigh in as to whether this would be accurate. Thank you.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by nickytraps; 10-26-2018 at 09:53 AM. Reason: Added additional info

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,619

    Re: VBA+Delete duplicate rows ignoring certain columns

    Hi,

    The second approach shall do the job. You may code it also this way:
    Please Login or Register  to view this content.
    note parentheses around arr passed as argument to removeduplicates - they are needed here
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    06-28-2018
    Location
    New York
    MS-Off Ver
    MS Office 2010
    Posts
    184

    Re: VBA+Delete duplicate rows ignoring certain columns

    Thank you Kaper, I really appreciate the information and code. Forgive my questions but I am very new to coding and trying to learn.
    In the code you provided I assume 0 to 18 represents columns B to V excluding G and H?

    And the line arr(i) = IIf(i < 5, i + 1, i + 3) is basically looping through columns B to V and saying:
    "if columns are B to E move right to the next cell by one, otherwise move right 3 cells (skipping G&H) arriving at column I?

    Lastly I am not familiar with ReDim. I've read that it relates to resizing an array, but still not quite clear. Thanks again for your help and time.
    Last edited by alansidman; 10-28-2018 at 03:25 AM.

+ 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 Duplicate Rows After Comparing 35 Columns
    By Lefemmenikita in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2014, 04:28 PM
  2. [SOLVED] Move data on duplicate rows (different columns) to one row and delete extra rows?
    By Sagwa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2014, 08:25 AM
  3. [SOLVED] Delete rows that have duplicate data in certain columns
    By aarodn in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-23-2013, 07:48 PM
  4. Replies: 6
    Last Post: 03-04-2013, 12:03 AM
  5. Delete duplicate rows with same data in certain columns for million rows
    By amlan009 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-08-2012, 12:53 AM
  6. Delete Duplicate Rows based on All columns
    By king12yan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2010, 02:36 PM
  7. Delete Duplicate Rows Based only 2 columns.
    By ebbo in forum Excel General
    Replies: 2
    Last Post: 02-18-2010, 11:27 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