Remove duplicates and retain one. Cross-linked cases

DeeExcel

New Member
Joined
Jan 6, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi all

I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if the community could shed some light to my darkness :)

What I'm trying to do is remove the duplicates + all other cross-linked cases and retain one for counting. It doesn't matter which of the cases is counted.

A sample of the table looks as below:

DateCase NoCross Linked Case No
03-Jan-20192019-12002019-1205
03-Jan-20192019-12002019-1206
04-Jan-20192019-12052019-1200
04-Jan-20192019-12052019-1206
04-Jan-20192019-12062019-1200
04-Jan-20192019-12062019-1205

Multiple rows with different Case Nos are created for let's say one interaction with the customer and then cross-linked with each other to denote that its coming from one interaction. But because of this structure, a simple use of remove duplicates didn't work for me, it retains 3 unique case no. instead of counting it as one.

I don't know if there's a way to find all the cross linked case no and perhaps assign a single unique number for all the rows? or any other way to achieve the desired single count.

Thanks all!

D
 
According to your example, you should also include the data 2019-0135964

1578886843316.png


Try the following macro, if your data is in columns B and C and starts in cell B2, the result will be in column E.

Book1
ABCDE
1CaseCrossResult
2431431
3175969175
4175159161
5159969964
6159175173
7161164
8164161
9964167
10167964
11969159
12969175
13173960
14960173
15
Sheet


VBA Code:
Sub Remove_duplicates()
  Dim c As Range, dic1 As Object, dic2 As Object
  Set dic1 = CreateObject("Scripting.Dictionary")
  Set dic2 = CreateObject("Scripting.Dictionary")
  For Each c In Range("B2", Range("B" & Rows.Count).End(xlUp))
    If Not dic1.exists(c.Value) Then
      If Not dic2.exists(c.Value) Then dic1(c.Value) = Empty
    End If
    dic2(c.Offset(, 1).Value) = Empty
  Next
  Range("E2").Resize(dic1.Count).Value = Application.Transpose(dic1.keys)
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Remove_duplicates) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Excel 365 has array function =UNIQUE
That is slightly misleading. To have the the UNIQUE function you not only require Office 365, but you also need to be registered in the 'Insiders' program and even then you need to be one of the chosen 'Insiders' that Microsoft has decided to release those new functions to as they release them only in stages to Insiders.
 
Upvote 0
That is slightly misleading. To have the the UNIQUE function you not only require Office 365, but you also need to be registered in the 'Insiders' program and even then you need to be one of the chosen 'Insiders' that Microsoft has decided to release those new functions to as they release them only in stages to Insiders.

@Peter_SSs :unsure: :unsure: :unsure:
That is strange - I have not knowingly registered as an 'Insider' and my Account does not show as being registered (although there is an open invitation to do so)
I never receive update emails from the 'Insider' program
I think I had better investigate ?
Thanks
 
Upvote 0
I have not knowingly registered as an 'Insider' and my Account does not show as being registered (although there is an open invitation to do so)
That also is strange. I have not seen any notification that those new functions shave been released to all Office 365 subscribers although that was always the eventual intention. I'll also see if I can find further information.

Microsoft's Help for the UNIQUE function still notes that it is a "beta features, and currently only available to a portion of Office Insiders "
 
Upvote 0
Excel 365 has array function =UNIQUE which is placed only in cell E2 in example below and Excel auto-creates entries in E3 and E4

The formula in E2
=UNIQUE(B2:B7)
Does column return the required results ?

View attachment 3802

Thanks, please see above image sent to Dante for a more detailed table. (I think I should have added more Case No. initially)

The end result I am hoping to get is just a single case no, can be either of the three (2019-1200, 2019-1205 and 2019-1206) in Column E. The reason is all three case no. are cross-linked with each other.

A bit of background is that for each question a new Case No is created. But instead of counting the questions (where the UNIQUE formula could be applied), we want to instead count the number of interaction. So rows 2-7 is just one interaction.
 
Upvote 0
Thanks, please see above image sent to Dante for a more detailed table. (I think I should have added more Case No. initially)

The end result I am hoping to get is just a single case no, can be either of the three (2019-1200, 2019-1205 and 2019-1206) in Column E. The reason is all three case no. are cross-linked with each other.

Could you try the macro?

Book1
ABCDE
1CaseCrossResult
22019-12002019-12052019-1200
32019-12002019-1205
42019-12052019-1200
52019-12052019-1206
62019-12062019-1200
72019-12062019-1205
Hoja4
 
Upvote 0
@DeeExcel (ref my discussion with @Peter_SSs above)

You use Excel 365
- does your build give you access to formula =UNIQUE ?
- are you registered as an 'Insider' ?
 
Upvote 0

Forum statistics

Threads
1,215,944
Messages
6,127,835
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top