Check a shifting range with numbers for duplicates and highlight?

NessPJ

Active Member
Joined
May 10, 2011
Messages
431
Office Version
  1. 365
Hi,

I am looking for a way to check for duplicates in a moving range and highlight them.

For example i have Columns K, L, M, N roughly 2000 lines filled with numbers and i want every Cell to check the surrounding 36 Cells for a duplicate and when there is, highlight it.

Is this possible?
 

Attachments

  • mrexcel_chkdup.jpg
    mrexcel_chkdup.jpg
    117 KB · Views: 13

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try

Book1
IJKLMNO
1
236079
3965862
496219
5501979
6
7
8
9
10
11
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:M19Expression=IF(K2="","",IF(AND(COUNTIF(K:K,K2)=1,COUNTIF($K$2:K2,K2)=1),FALSE,COUNTIF(K:K,K2)=COUNTIF($K$2:K2,K2)))textNO
 
Upvote 0
When you say "Active Cell" do you mean the cell currently being selected? If so, you'd need to use VBA.
 
Upvote 0
When you say "Active Cell" do you mean the cell currently being selected? If so, you'd need to use VBA.

I mean a piece of VBA that will do this duplicate check for every Cell inside this table (not just the selected/active cell).
 
Upvote 0
Try

Book1
IJKLMNO
1
236079
3965862
496219
5501979
6
7
8
9
10
11
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:M19Expression=IF(K2="","",IF(AND(COUNTIF(K:K,K2)=1,COUNTIF($K$2:K2,K2)=1),FALSE,COUNTIF(K:K,K2)=COUNTIF($K$2:K2,K2)))textNO

Thanks, but this does not seem to check a shifting range. Look at the value '30' in the attachment of this post. The value does not exist anywhere else in the range (but it does exist within the entire table).
 

Attachments

  • mrexcel_chkdup2.jpg
    mrexcel_chkdup2.jpg
    33.1 KB · Views: 6
Upvote 0
Can you show entire table and your expected results.
 
Upvote 0
check the surrounding 36 Cells
This seems pretty vague. In you images it looks like in the first image the 36 cells starts 1 row above the "active cell", in the second image it looks like the 36 cells starts 3 rows above and in the third image it starts 4 rows above. Can you clarify?


do this duplicate check for every Cell inside this table
So, in your first image, why have you chosen to highlight the two 96 values and not others like these?

1733827633685.png
 
Upvote 0
Can you show entire table and your expected results.

Reflex WEB Locations with new signs 08122024.xlsb
KLMNOPQRST
1Headers
2For every Cell in the table, the surrounding 35 Cells should be checked for a duplicate.
3
4So 36 Cells in total would mean a Range selection of 4 Rows above the Cell, 4 Rows below the Cell and Columns K, L, M and N.
5Note: At the top of the table it would not be possible to select 4 Rows above the selected Cell for the duplicate check.
632179339See Example 1.
762733867
856432873Example 1 with value 32. There is no duplicate 32 in this range.
957635862
1096335548Example 2 with value 62. There is a duplicate within the range.
1152068492
1266672051
1395467683
1449253368
1564866745
1633462464
1788318676
1885973753
1929208695
2039092247
2122857007
2295975119
2330156226
2488416167
2548633137
2690869926
2796622127
2889550535
2932701991
3025658885
3145671428
3292389596
3398584533
3498072931
3598904996
3652843376
3728398164
3802279874
3949697410
4008240754
4189936275
4258302202
4368260307
4424213762
4528234776
4660779734
4753420435
4823071024
4932159340
5096738767
5124768524
5243817310
5336797861
5490392904
5520595577
5603824650
5758320736
5835654428
5996162110
6052853421
6108330151
6290574475
6354508280
6488425336
6562783868
6658190686
6795126868
6869385741
6908996134
7008272891
7164164458
7293708630
7365582521
7468946118
7504859613
7682379361
7725493244
7882671991
7945982706
8056832883
8162524294
8293261742
8306476567
8460472947
8534346137
8686570578
8768873786
8896163710
8925599275
9080024932
9190238725
9226777095
9354905465
9426020663
9529854575
9663516478
9756339313
9802324517
9955264959
10032264849
10165796544
10263954707
10343179812
10403611605
10586863224
10660185995
10705061050
10844268018
10909356945
11086853779
11155609865
11250969479
11365160777
11408443402
11549080658
11636161091
11744377756
11862729689
11923386001
12052319451
12190247044
12236280846
12362279981
12455182265
12592221584
12690915769
12769647575
12834773052
12986523752
13002923650
13184060158
13224967782
13342897286
13408606206
13594871279
13605122637
13783402290
13859742952
13928507512
14058303463
14162909516
14298873962
14326739419
14462629512
14508672874
14686479791
14734455754
14888234890
14968898513
15069831723
15125199085
15228759024
15336699662
15492402615
15559826773
15649338384
15738331909
15849082198
15954432787
16062549243
16106054727
16206983076
16380585939
16488943314
16585821236
16608518502
16755762482
16888167963
16962288677
17034108780
17109795581
17224675906
17395797384
17482439677
17594215253
17652439357
17785993382
17826544696
17965385513
18095089097
18159370312
18234061756
18366468734
18445835044
18555724528
18669983860
18740265706
18858026062
18990871767
19090950423
19149781993
19203123585
19302466099
19466397338
19523130768
19685490854
19724209969
19854902401
19922259339
20022170715
20190998936
20225828381
20394028565
20456652146
20594339585
20652237779
20748293896
20849059747
20956328465
21053918008
21182153894
21220494824
21394324573
21445676803
21562488429
21608072827
21723928209
21880020837
21996046347
22046953453
22158764120
22253212482
22342081418
22439894407
22534636723
22689453370
22723691478
22845176468
22943780192
23022294324
23123413129
23208758447
23328765922
23464854777
23596183509
23628264583
23746936848
ShiftingRangeCheck
 
Upvote 0
This seems pretty vague. In you images it looks like in the first image the 36 cells starts 1 row above the "active cell", in the second image it looks like the 36 cells starts 3 rows above and in the third image it starts 4 rows above. Can you clarify?



So, in your first image, why have you chosen to highlight the two 96 values and not others like these?

View attachment 120224
1. Yes, so as showing an example of a multitude of scenarios correctly. Its impossible to select 35 surrounding cells when you are in the top of the table. Once you go passed the top of the table this is actually possible. That is why each of the examples shows another scenario of the functionality.

2. No reason. I just picked 96 as an example.
 
Upvote 0
Does this do what you want then?

24 12 10.xlsm
KLMN
1Headers
2
3
4
5
632179339
762733867
856432873
957635862
1096335548
115268492
1266672051
1395467683
1449253368
1564866745
1633462464
1788318676
1885973753
1929208695
203992247
212285707
2295975119
2330156226
2488416167
2548633137
2690869926
2796622127
288955535
2932701991
3025658885
3145671428
3292389596
3398584533
349872931
3598904996
3652843376
3728398164
382279874
3949697410
40824754
4189936275
425830222
43682637
4424213762
4528234776
4660779734
475342435
482371024
4932159340
5096738767
5124768524
5243817310
5336797861
549039294
5520595577
563824650
575832736
5835654428
5996162110
6052853421
61833151
6290574475
6354508280
6488425336
6562783868
665819686
6795126868
6869385741
698996134
708272891
7164164458
7293708630
7365582521
7468946118
754859613
7682379361
7725493244
7882671991
794598276
8056832883
8162524294
8293261742
836476567
8460472947
8534346137
868657578
8768873786
8896163710
8925599275
908024932
9190238725
9226777095
9354905465
94262663
9529854575
9663516478
9756339313
982324517
9955264959
10032264849
10165796544
1026395477
10343179812
104361165
10586863224
10660185995
107561050
10844268018
1099356945
11086853779
11155609865
11250969479
1136516777
114844342
115498658
11636161091
11744377756
11862729689
1192338601
12052319451
12190247044
1223628846
12362279981
12455182265
12592221584
12690915769
12769647575
12834773052
12986523752
1302923650
131846158
13224967782
13342897286
134860626
13594871279
1365122637
13783402290
13859742952
13928507512
14058303463
14162909516
14298873962
14326739419
14462629512
1458672874
14686479791
14734455754
14888234890
14968898513
15069831723
15125199085
15228759024
15336699662
15492402615
15559826773
15649338384
1573833199
1584982198
15954432787
16062549243
161654727
1626983076
16380585939
16488943314
16585821236
166851852
16755762482
16888167963
16962288677
17034108780
1719795581
1722467596
17395797384
17482439677
17594215253
17652439357
17785993382
17826544696
17965385513
1809589097
1815937312
1823461756
18366468734
18445835044
18555724528
18669983860
1874026576
1885826062
18990871767
1909095423
19149781993
1923123585
1932466099
19466397338
1952313768
1968549854
19724209969
1985490241
19922259339
2002217715
20190998936
20225828381
2039428565
20456652146
20594339585
20652237779
20748293896
2084959747
20956328465
2105391808
21182153894
21220494824
21394324573
2144567683
21562488429
216872827
2172392829
218802837
2199646347
22046953453
22158764120
22253212482
2234281418
2243989447
22534636723
22689453370
22723691478
22845176468
2294378192
23022294324
23123413129
2328758447
23328765922
23464854777
2359618359
23628264583
23746936848
NessPJ
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K6:N237Expression=COUNTIF($K2:$N10,K6)>1textNO
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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