+ Reply to Thread
Results 1 to 11 of 11

Concatenate 2 ranges with a countif formula.

Hybrid View

  1. #1
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Concatenate 2 ranges with a countif formula.

    Quote Originally Posted by DonkeyOte post#3
    If you're trying to ascertain as to whether or not duplicates exist you can test the output of the above to the count of non-blank/non-null entries*
    (method for doing this will depend on whether range contains Nulls and whether or not if A is not blank B might be and vice versa)
    Does the above not cover this ?

    ie compare unique count to count of non-blanks - if not the same you have duplicates.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Concatenate 2 ranges with a countif formula.

    Another alternative to the above would be to use a Frequency Array

    =COUNT(IF(FREQUENCY(IF(A7:A9&C7:C9<>"",MATCH(A7:A9&"@"&C7:C9,A7:A9&"@"&C7:C9,0)),ROW(A7:A9)-ROW(A7)+1)>1,1))
    confirmed with CTRL + SHIFT + ENTER

    (if greater than 0 then duplicates)
    Last edited by DonkeyOte; 08-17-2010 at 07:46 AM. Reason: typo in formula re: @

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Concatenate 2 ranges with a countif formula.

    A unique list in column D based on the values in columns A and C

    Sub unique()
      [D1:D18] = [if(countif(offset(D1,,,row(A1:A18)-if(row(D1:D18)=1,0,1)),A1:A18 & C1:C18)=0,A1:A18 & C1:C18,"")]
    End Sub

  4. #4
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Concatenate 2 ranges with a countif formula.

    DonkeyOte,
    The last formula you gave me works perfectly. I didn't know I could use @ to concatenate 2 ranges.
    Thanks,
    Xrull

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Concatenate 2 ranges with a countif formula.

    Concatenation is achieved with & ... the use of @ is to delimit the two values from one another so as to avoid false positives

    Consider

    A1: Car C1: pet
    A2: Carpet C1: [blank]

    Comparing A1:A2&C1:C2 it would appear that we have 2 instances of Carpet whereas in fact we have just one.

    To avoid the false positive we delimit A & C with a character otherwise not found in the strings - this way Car@pet and Carpet@ do not get flagged as a match.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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