+ Reply to Thread
Results 1 to 6 of 6

Signify direction of duplicate values in a column

  1. #1
    Registered User
    Join Date
    04-28-2016
    Location
    Atlanta, GA
    MS-Off Ver
    Office Pro 2016
    Posts
    12

    Signify direction of duplicate values in a column

    I have a column of about 9700 values, many of which are duplicates. What I would like to do is be able to look at a cell and determine whether its duplicate value occurs before (lower row number) or after (higher row number) than that one.

    My plan was to use a combination of for/next and .findnext, but I've at this point in my two-weeks of vba experience not been able to make .find or .findnext work. Basically my plan was to change the right border of a cell's value for "appears below" and the left border for "appears above." This would avoid the confusion of a cell sharing a top or bottom border with another cell.

    Does anybody have any suggestions? It seems like a fun puzzle to work out, but I think I'm out of my depth.

    Thanks very much to all of you.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Signify direction of duplicate values in a column

    As requested, but could also do something more comprehensive like actually listing the cell address of the duplicate.

    Change col to whatever column your data is in (here, 2 = Column B). If you want further refinement, a sample data set would be helpful.

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Signify direction of duplicate values in a column

    You could do this with Conditional Formatting (CF).

    This CF formula is for column B "appears below"
    =AND(B1<>"",COUNTIF(B1:$B$65536,B1)>1)

    This CF formula is for column B "appears above"
    =AND(B1<>"",COUNTIF($B$1:B1,B1)>1)
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    04-28-2016
    Location
    Atlanta, GA
    MS-Off Ver
    Office Pro 2016
    Posts
    12

    Re: Signify direction of duplicate values in a column

    Here's a sample of the data I'm working with (gonna be a long post, hope I'm not violating any rules):

    In this data, you can see that the value of cell A6 would be the same as A376. Ideally, this would mean I'd see the right border colored green on A6 and the left border colored green on A376. A1 is, of course, a header.

    stockcode
    30791014
    30664113
    8698927
    8698933
    30682111
    30682087
    30682101
    31253113
    8682185
    8682093
    8622614
    8624196
    9496979
    31217061
    8624353
    9134945
    8698589
    30721726
    30721725
    30721727
    8641200
    30721712
    30721713
    30721714
    9499024
    9499026
    9499025
    39965829
    39965828
    39965827
    8671059
    8673473
    39963435
    39963437
    39963433
    8682177
    9166732
    31414237
    9148136
    30721974
    31263245
    8641722
    8685516
    30664041
    30664042
    30721383
    30721382
    30721717
    30721716
    30721696
    30721698
    30721715
    9192992
    30721709
    30664340
    30664338
    39891781
    39891793
    39998304
    39891775
    39891787
    39998294
    39891778
    39891790
    39998299
    39892724
    39967700
    39967927
    39892727
    39967698
    39967924
    39967948
    39967699
    39967926
    39967949
    39885111
    39885109
    39885110
    9155288
    1343999
    30721719
    30721721
    30721720
    8641254
    9499310
    9204062
    8624222
    9204061
    8641255
    9204060
    9499904
    8637222
    30660542
    9499153
    8637714
    8637427
    9438235
    30739571
    9438236
    8698154
    8637076
    30728403
    9814069
    9192678
    8637215
    30669774
    8691888
    8633764
    9499034
    8637392
    30716660
    31217622
    31217623
    31217625
    8637393
    30715805
    8622723
    8622724
    8622731
    8622732
    8622721
    8622727
    8622728
    8622725
    8622726
    8622729
    8622730
    9499266
    9499267
    8637408
    9499398
    9499397
    9499636
    8651385
    8651382
    8651379
    9499637
    8637409
    9438241
    31267436
    30661774
    9488735
    8674874
    30618547
    9166346
    31359474
    31470478
    31217667
    30863733
    9438246
    9438247
    8624286
    30710979
    9438248
    9438249
    8624284
    8691912
    8698727
    9499758
    8698074
    30669774
    8624286
    30710979
    30795247
    8624284
    8691912
    9499758
    8698074
    30669774
    8624286
    30710979
    9499164
    8624284
    8691912
    8698727
    9499758
    8698074
    9499478
    9438237
    9438287
    30660792
    30744345
    30744346
    30744347
    8622338
    8622838
    8622839
    8698122
    8698123
    9166697
    8622840
    8622981
    30772053
    8671036
    30796586
    30664195
    8622943
    8685753
    8698060
    8698318
    8698996
    8698997
    9190803
    9190936
    9484507
    9484631
    8685503
    30673258
    30673259
    1188364
    8685839
    9499414
    9499559
    9451649
    9481791
    31373831
    30664327
    31202244
    274511
    8666253
    30695184
    9451408
    274511
    8666253
    8682133
    9499038
    274511
    8666253
    9499020
    274511
    8666253
    8633140
    274511
    8666253
    30660592
    9162391
    274511
    8666253
    30748020
    8698501
    274511
    8666253
    9451348
    274511
    8666253
    9451347
    274511
    8666253
    9162393
    274511
    8666253
    30748782
    8698499
    274511
    8666253
    30695185
    8698502
    274511
    8666253
    8622748
    274511
    8666253
    9499019
    274511
    8666253
    9451346
    274511
    8666253
    9451345
    274511
    8666253
    9162395
    274511
    8666253
    30789048
    9499551
    274511
    8666253
    8698504
    274511
    8666253
    9162394
    9162392
    8633138
    8698500
    9491784
    8622862
    8698503
    8698046
    8671048
    8671050
    8698167
    8671047
    8671049
    8698155
    8698157
    8671055
    8671056
    8671057
    39985061
    39986945
    39985049
    39985288
    8698225
    8698857
    8637171
    9499549
    30660838
    8698223
    9499061
    9481247
    8682095
    8698041
    8685885
    8685762
    9496986
    30741604
    30741605
    30741633
    30741597
    8698230
    8698856
    30741600
    30741601
    30741632
    30741096
    30741101
    30741232
    30741233
    30741098
    30741598
    30741599
    30741596
    30741602
    30741603
    30741634
    8624350
    9204956
    8622875
    8622876
    8623108
    9452189
    30660443
    9452189
    30660437
    30660439
    9452189
    39966522
    39966521
    39966520
    30730085
    39899313
    39899316
    39899312
    39899315
    39899311
    39899314
    9196876
    9196141
    9197488
    9196183
    9188998
    9438263
    39984780
    39984779
    39984781
    39984778
    30775885
    9452314
    39984788
    39984787
    39984789
    39984786
    30682110
    30682111
    8698043
    8637076
    9814069
    9192678
    30698360
    30660645
    30786670
    30786671
    8637076
    30669774
    8691888
    9814069
    9192678
    30698360
    30786663
    30786664
    30786665
    274511
    8666253
    30664605
    274511
    8666253
    30664609
    30695338

    I tried the code above and let it run for a couple minutes but eventually had to break out. Nothing was noticeably different with formatting.

    Thanks again, folks.

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Signify direction of duplicate values in a column

    Pasted your data set into a column B. The code I posted ran in less than a second and had noticeable results.

    Rows 6, 102, 104, and 105 were the first with left only borders, indicating duplicates below.
    Rows 162, 163, and 164 were the first with two borders.
    Rows 171, 172, and 174 were the first with right borders, indicating duplicates above.

  6. #6
    Registered User
    Join Date
    04-28-2016
    Location
    Atlanta, GA
    MS-Off Ver
    Office Pro 2016
    Posts
    12

    Re: Signify direction of duplicate values in a column

    Yeah, I could definitely see it running faster on 400 rows than on 9700. Maybe I just need to be more patient. Thanks for the help, I really appreciate it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. detecting duplicate values in a column (values are made of formula)
    By louiemangaring in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2015, 06:25 AM
  2. Hot to get the values in right direction ?
    By jd16 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-17-2013, 11:24 AM
  3. Create a row (or column) of non-duplicate values from a column containing duplicate values
    By 777volkov777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 11:11 AM
  4. what does + signify
    By costadina in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-31-2013, 05:52 PM
  5. Using wildcards when filtering - anything exist to signify a number?
    By jlax34 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-16-2013, 08:49 PM
  6. [SOLVED] Need Urgent help on Adjacent values of Duplicate column values should be be in single row.
    By anto_01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2012, 09:55 PM
  7. Replies: 5
    Last Post: 03-22-2012, 01:25 PM

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