Unique Combination of Values

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Hi, Peter

I found #post3 code very useful for me and I am using it. I want if you could adapt my need will be great of you.

I want to find unique among any of 14 columns B To O, selecting continuous or alternate 1, 2, 4, 6, or all 14
In example below I have shown 3 columns C, G, K in my selection.


Book1
ABCDEFGHIJKLMNO
1DateP1P2P3P4P5P6P7P8P9P10P11P12P13P14
2DateP1P2P3P4P5P6P7P8P9P10P11P12P13P14
301/12/20132X2111X1112X11
402/12/201322X121XX21212X
503/12/201311111X1X11XX12
604/12/201311121112X111X1
705/12/20131X11X12X11111X
806/12/201311122X111X111X
907/12/201311X111121X11X1
1008/12/2013121111211X1112
1109/12/201322X2112X211X12
1210/12/2013X1111221121X11
1311/12/20131211X1111XX1XX
1412/12/2013112X2212X11X21
1513/12/20131X1X1221111222
1614/12/2013XX11211222X111
1715/12/201322222X1112X2X1
1816/12/2013X111XXX111X122
1917/12/201322X1212121X11X
2018/12/2013X1121121X2X221
2119/12/2013111212X22X1211
2220/12/20132111X211X1X122
Sheet1


I want result in sheet 2 as shown column B count match.


Book1
ABCDE
1P2|P6|P10Count MatchP2P6P10
2X|1|12X11
32|1|13211
41|X|121X1
51|1|11111
61|X|X11XX
71|1|X111X
82|1|X221X
91|2|21122
101|2|12121
11X|2|11X21
12X|1|21X12
132|X|212X2
141|1|21112
151|2|X112X
Sheet2


Using Excel Version 2000

Thank You

Regards,
Kishan

<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>
 
Last edited by a moderator:
I am trying code with my data #post1 selecting column C, G, K it produce error ‘438’ after debug highlight following line.
Code:
.Columns("A").RemoveDuplicates Columns:=1, Header:=xlNo
.
I knew there was a third remark I was going to make.

3. RemoveDuplicates is not available in Excel 2000.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi Peter,

I just add code to my original file which contain at present 2478 rows, code run perfect if I select any 2 columns, but it stop if I select 3 or more it produce error '13' and highlight at line below.
Code:
s = Join(Application.Index(a, i, 0), "|")

Please could you take a look?

Thank you

Regards,
Kishan
 
Upvote 0
Hi Peter,

I just add code to my original file which contain at present 2478 rows, code run perfect if I select any 2 columns, but it stop if I select 3 or more it produce error '13' and highlight at line below.
Code:
s = Join(Application.Index(a, [COLOR="#FF0000"][B]i[/B][/COLOR], 0), "|")

Please could you take a look?

Thank you

Regards,
Kishan
I haven't been able to reproduce that error.

Does it error if you select any 3 columns or is it one particular column that seems to be the problem?

Run the code again & 'debug' when it errors.
Then hover your cursor over the "i" in that yellow highlighted line and note the pop-up number.
Suppose that number is 15, then the problem row in your sheet is row 16. Have a look at that row and see if there is anything unusual about it, especially in those columns that you have highlighted.

You could also then delete most of the rows below the problem row, but leave a couple, and most of the rows above the problem row (unless it is row < 5) but leave a couple above too if possible.

Run the code again and if it still errors on that same set of data, post that small set of data and advise which row is the problem.
Also advise if it seems to be one particular column in a group that is causing the error.
 
Last edited:
Upvote 0
Run the code again & 'debug' when it errors.
Hi Peter,

Very strange situation 14 column B:O in general whatever column is selected in any order reproduce error

With 5000 lines code works if I select any “1” column, if I select 2 col give error 'debug' show "i" =1
With 2000 lines code works if I select any “2” column, if I select 3 col give error 'debug' show "i" =1
With 1100 lines code works if I select any “3 or 4” column, if I select 5 col give error 'debug' show "i" =1
With 800 lines code works if I select any “5 or 6 ” column, if I select 7 col give error 'debug' show "i" =1
With 600 lines code works if I select any “7, 8 or 9” column, if I select 10 give error 'debug' show "i" =1
With 400 lines code works if I select any “10, 11,12 or 13” column, if I select 14 give error 'debug' show "i" =1
With 200 lines code works if I select all “14” column

This is what I have noticed tried all very carefully as line increase less column filters. And in all in all situation 'debug' show "i" =1


Regards,
Kishan
 
Upvote 0
I can't reproduce the problem. I guess again it could relate to your very old Excel version.
Try ..
1. Add a new Dim j As Long at the top of the code, then
2. Remove that problem line & replace it with these blue lines of code.

Rich (BB code):
For i = 1 To UBound(a)
  <del>s = Join(Application.Index(a, i, 0), "|")</del>
  s = vbNullString
  For j = 1 To UBound(a, 2)
    s = s & "|" & a(i, j)
  Next j
  s = Mid(s, 2)
  If d.exists(s) Then
 
Upvote 0
I can't reproduce the problem. I guess again it could relate to your very old Excel version.
Try ..
1. Add a new Dim j As Long at the top of the code, then
2. Remove that problem line & replace it with these blue lines of code.

Rich (BB code):
For i = 1 To UBound(a)
  <del>s = Join(Application.Index(a, i, 0), "|")</del>
  s = vbNullString
  For j = 1 To UBound(a, 2)
    s = s & "|" & a(i, j)
  Next j
  s = Mid(s, 2)
  If d.exists(s) Then
Hi Peter,

Yes this did the trick I tried code with 5000 lines and it is working flawless like a magic.

Problem SOLVED.

Thank you for your passion and for helping me.

Kind Regards,
Kishan
 
Upvote 0
Hi Peter,

Yes this did the trick I tried code with 5000 lines and it is working flawless like a magic.

Problem SOLVED.

Thank you for your passion and for helping me.

Kind Regards,
Kishan
Glad we got there in the end.:)

BTW, time to upgrade to a newer Excel version. ;)
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,393
Members
449,446
Latest member
CodeCybear

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