+ Reply to Thread
Results 1 to 10 of 10

Find duplicate rows base on combination of two columns / replicating sumproduct formula

  1. #1
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Find duplicate rows base on combination of two columns / replicating sumproduct formula

    Hi,

    I found the thread "Find count of Unique or Duplicate Values based on Concatenated values in 2 columns" which is very close to what I am trying to achieve also but I need to replicate the formula in VBA.

    http://www.excelforum.com/excel-form...2-columns.html

    I've attached a mock excel file to help try demo what I am trying to do


    I'm trying to replicate a formula which looks like this:


    Please Login or Register  to view this content.
    But the equivalent in VBA so that I can loop through each row and if count duplicates is greater than one, action a particular macro for that row.

    Below is an attempt I tried but raised an error. I've tried various other permutations of this but without success.

    Please Login or Register  to view this content.


    Any help would be very much appreciated.
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Select your Data Range and select Data Menu>>Remove Duplicates


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Hi, sorry I should have pointed out I am not trying to delete duplicates but to highlight them by colouring in their cell red fill. Also this is part of a bigger automation project hence wanting to do it with vba rather than settling for sumproduct formula.

  4. #4
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Also, it may be that I need to generalize this for n combinations of columns rather than just 2 columns.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Quote Originally Posted by JSutar View Post
    highlight them by colouring in their cell red fill
    If that is the case then use your formula in the Conditional Formatting to achieve this

  6. #6
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Thanks Sixthsense.

    That is one possibility, using formula based conditional formatting. However, the creation of columns C and D in the excel I mocked were for illustration purpose. In fact, I want to avoid writing these columns in my actual program. In my actual program I would have just the data columns A and B.

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Actually you don't need the helper column.

    Refer the attached file in which I used the formula's inside the Conditional Formatting
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Still no quite there yet

    1) It only highlights the second/last occurrence of the duplicate, I need to highlight both first and second, pairs of duplicate rows (all duplicate rows if more than two).

    2) Need to learn how to replicate this in VBA

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    Quote Originally Posted by JSutar View Post
    I need to highlight both first and second, pairs of duplicate rows (all duplicate rows if more than two).
    Check this revised file
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    12-02-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: Find duplicate rows base on combination of two columns / replicating sumproduct formul

    That's excellent thank you. But now the question arises how to implement that same formula using condition formatting (via VBA) or hard code the color using VBA.

+ 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] Find non-duplicate rows between columns Name and Tag
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-28-2014, 06:04 AM
  2. Replies: 1
    Last Post: 02-20-2014, 12:24 PM
  3. VBA code to find duplicate values within multiple rows and columns
    By pcbpinoy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2011, 09:04 PM
  4. How to find duplicate rows where columns contain data of different types
    By olechkq in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2010, 01:18 PM
  5. Replies: 2
    Last Post: 03-27-2010, 12:43 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