+ Reply to Thread
Results 1 to 16 of 16

Count duplicate numbers

  1. #1
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Count duplicate numbers

    Hello,

    I have a list of numbers and I'd like to count the duplicates but the only way to explain what I'd like to do is to show you in a workbook.

    Thank you for your time in advance

    Sans
    Attached Files Attached Files
    Last edited by sans; 11-03-2011 at 09:52 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Count duplicate numbers

    ..........
    Last edited by Jack in the UK; 11-03-2011 at 07:20 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Count duplicate numbers

    ...................................
    Last edited by Jack in the UK; 11-03-2011 at 07:20 AM. Reason: Going Mad !

  4. #4
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Count duplicate numbers

    ....................

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count duplicate numbers

    Try the UDF:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Count duplicate numbers

    Please Login or Register  to view this content.
    Attached Files Attached Files



  7. #7
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Count duplicate numbers

    Thank you very much for your replies.

    How do I get the result for each row compared to its previous rows? For instance, B30:H30 compared to B29:H29, B28:H28 etc, then B31:H31 compared to B30:H30,B29:H29 etc. So basically get the all the counts for each row compared to the previous 11 rows.

    I hope I am making sense,

    Thank you
    Sans

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count duplicate numbers

    Quote Originally Posted by sans View Post
    How do I get the result for each row compared to its previous rows? ...
    I think so - see attachment.
    But the formula with OFFSET - not a good idea. Maybe fill the table with macro rather than UDF?
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Count duplicate numbers

    This is exactly what I was looking for! Thank you so much for your help!!! It works great.

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Count duplicate numbers

    @Nilem

    Wouldn't this sufffice ?

    Please Login or Register  to view this content.

  11. #11
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count duplicate numbers

    Quote Originally Posted by snb View Post
    @Nilem
    Wouldn't this sufffice ?
    Please Login or Register  to view this content.
    @Snb
    It's a very good idea and a very nice code.
    Maybe I'm wrong, but I do not like to use Application (WorksheetFunction) in the code.

  12. #12
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Count duplicate numbers

    Is it possible for the code to include a range such as A1:G1 for the numbers to be checked and results which I can easily alter?
    Thank you

  13. #13
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count duplicate numbers

    Can you show in the book (file) what solution do you expect?

  14. #14
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Count duplicate numbers

    The solution is great, it is exactly what I am looking for. However, when I copy the sheet to another workbook, I have to change the ranges of the numbers. And I don't quite understand how to do it in the vba code as I can't see any range such as C1:I1 that can be changed.

  15. #15
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count duplicate numbers

    Sans, do not look the VBA .
    UDF is a custom function that works like a normal function of the sheet.
    In the formula:
    Please Login or Register  to view this content.
    $B9:$H9 is the first range
    OFFSET($B9:$H9,-K$7,0) - this is the second range, which is offset from the first range on the K$7 rows up.
    Just type the address ranges in the formula as needed.

    To make it easier to understand. For example, you want to count the duplicates in ranges B12:H12 and A2:F2
    Please Login or Register  to view this content.
    If you work in a different workbook, copy the Module1 with code function to your book.
    Last edited by nilem; 11-03-2011 at 02:44 PM.

  16. #16
    Valued Forum Contributor sans's Avatar
    Join Date
    10-19-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    550

    Re: Count duplicate numbers

    Thank you for the explanation. I did what you suggested but I just managed to get it working as I didn't realize than the numbers in the offset by rows heading were part of the formula, so I wasn't using them and was getting wrong results. Everything works great now.

    Thank you again for your help!

    Sans

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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