Repeating Numbers in Tabled Data

cotech_10

Board Regular
Joined
Sep 11, 2010
Messages
135
Office Version
  1. 2016
Platform
  1. Windows
Hi All,


I have created a Table that has 11 Columns and 18 Rows, contained in this Table is number data in each cell. What I would like to do is to create a macro that can calculate
and display the number of repeated numbers in any given grouping of lines and produce the results to the right of the Tabled Data as per Attachment 1.

The macro would require input for any line combinations

I have given (3) such examples to the right of this Table:

1. In this first example I have selected Lines 1 to 3 of this table for analysis.

2. In the second example I have selected Lines 3 to 7 for analysis

3. In the third example I have selected two non consecutive lines being
Lines 8 and 17.


As mentioned the "output data" can be written to the right of the Table as per the attachment with automatic calculations on the following:



1. "No of Repeating Numbers" = This total is simply the total of all numbers appearing in the given line

So for this analysis there are 9 Numbers that have repeated in the line grouping "Lines 1 to 3"

2. "No of offset numbers" = This is the total of the repeated numbers in this line that appear in the "Offsets" Line at E2..K2

If we refer to Lines 1 to 3 analysis out of the 9 repeating numbers there are (4)numbers that appear in the "Offset" range located at E2..K2. they are 45,100,103 & 108

These numbers can be colour coded as per the attachment output.



I look forward in hearing back from someone soon.



Kind Regards
 

Attachments

  • Remove Duplicates.JPG
    Remove Duplicates.JPG
    208.3 KB · Views: 12
You're welcome. Thanks for the follow-up. :)

Also, thanks for using XL2BB - makes it much easier. (y)
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Peter,

Spoke abit too soon... lol. I just discovered that if you put a single value in Column N the calculations for
2. The Number of Offset numbers do not seem to have calculated properly. Please see attached

In the example I have provided I had specified single values in cells N13, N14 & N15 those being respectively Lines 1,2,3
I have highlighted those lines in Green.

Line 3 shows 240 as being a OFFSET number and has accordingly tallied.


PMacros.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQAR
1
2Offsets:3401036310845392100
3
4
5Col 1Col 2Col 3Col 4Col 5Col 6Col 7Col 8Col 9Col 10Col 11Output Analysis :No of Repeating NumbersNo of offset numbersOutput Data
6Line No:
7115101510825106353545501-39410153545100103106108240
82436100101102103104105106451083-7182678910111214151721334099100102103240
939924024089101001210314158,1753103108231392454
1046834997211140102105171,3,5,7,9,11,13,15,1727315678910111213141517213335404852100102103105106108240454
115593610067688333317-183122108454
126431038101111031548106782,4,6,8,1014367811154399100101102103105106392
1372111401021112131415161711035
14810080039210310210323139210639299200
1591011344104676883333301240
16101021446105369121518105
17111031548106721114010210517
1812104165010716171819202122
1913105175210813105175210823
20141061854109190191190192141063
2115107195611011103154810671
22161082058111676883333
231710910860112231232234454466108454
2418110226211316171819202122
25
26
Sheet1






Thanks and Regards
 
Upvote 0
Spoke abit too soon... lol.
Try making this change near the end of the code & do some more tests.

Rich (BB code):
.Sort Key1:=.Cells(1), Order1:=xlAscending, Header:=xlNo, Orientation:=xlLeftToRight
If d1.Count > 1 Then .Sort Key1:=.Cells(1), Order1:=xlAscending, Header:=xlNo, Orientation:=xlLeftToRight
 
Upvote 0
Hi Peter,

Once again just another amazing great effort and your fix solved that issue.
I am sure now that is the extent of what I intend to get out of this analysis and
very much appreciate your assistance.

The XL2BB add-in is just a great tool to use to provide data to you.. just easy to work with..

Thanking you once again..

:)
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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