+ Reply to Thread
Results 1 to 26 of 26

Generate Unique List 2 Columns

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Angry Generate Unique List 2 Columns

    Hi Guys,

    I have data organized in two columns. One column contains entries that describe different causes of error. The second column contains entries showing the error type. I need to generate a string that would look like this (as an example): "There were 3 error types Three, which were caused by Administrative and Human errors". I want to be able to generate a code that tells me what unique entries for causes of error exist for each error type and I want to put that in a string. Can anyone help me, please?

    Cause or Error Error Type

    Administrative Two
    Human Three
    Technology One
    Administrative Two
    Technology Three
    Human Two
    Human One
    Human One
    Technology Three
    Technology Three
    Technology Three

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Generate Unique List 2 Columns

    I don't quite understand how you are counting these.
    But if your headings are in row 1
    and values in Col A & B
    then
    this counts the errors based on the numbers, but your numbers don't match the error type

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Hey - thanks for the reply. I don't want to count them, I want the system to tell me (even a messagebox would work) what the causes of error were per error type. For example, looking at the extract below, I want the system to tell me "error types A were caused by Administrative, Human, and Technology causes, error types B were caused by Human causes, error types C were caused by Technology causes", etc.


    Cause or Error Error Type
    Administrative A
    Human B
    Technology C
    Administrative A
    Technology D
    Human A
    Human A
    Human B
    Technology A
    Technology A
    Technology A

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Generate Unique List 2 Columns

    How about just sorting and removing duplicates?

    A
    B
    1
    Cause of Error
    Type
    2
    Administrative A
    3
    Human A
    4
    Technology A
    5
    Human B
    6
    Technology C
    7
    Technology D
    Last edited by shg; 06-19-2014 at 05:37 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    It needs to be automated so that each time new data gets inputtrd into the same range, user would be able to see the that text.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Generate Unique List 2 Columns

    OK; so does my suggestion meet the criteria?

  7. #7
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    If you want to use the Excel Remove Duplicates method, then here's a small dataset to test it on, just to verify that it works as advertised.

    Dataset has obvious duplicates, and so quick and easy to remove these manually.

    3c
    3
    6
    1c
    10
    1
    4c
    5
    4c
    10
    1c

  8. #8
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    So what would be the vba code to have this automated and to pop up a messagebox displaying the summary information I mentioned?

  9. #9
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    just for completeness, if you try Excel's Remove Duplicates facility (either from ribbon or via VBA) on the small dataset posted above, you may see that it doesn't always work as advertised.

    appears to be somewhat buggy in fact.

  10. #10
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Thanks, but that doesn't seem to work. Any other suggestions, please?

    I can automate the data filtering to show only the unique rows but do not know how to generate the summary string after that.

  11. #11
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Generate Unique List 2 Columns

    Hi, this is a little long winded as I don't have the time to make the code smaller, but it works

    Please Login or Register  to view this content.
    You just need to duplicate the code depending on how many error types you are searching for.
    Like I said, it could be a bit smarter by putting in a loop but I don't have the time now.
    Last edited by Sean Thomas; 06-20-2014 at 09:25 AM.

  12. #12
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    another
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Type mismatch...

  14. #14
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    type mismatch where?? (feedback not helpful otherwise)
    alternative
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Thanks - this seems to work. Is there a way to make the system automatically pick the error types?

  16. #16
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    My previous comment was in response to Sean Thomas.

  17. #17
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    I got a type mismatch on this line: n = UBound(c)

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Generate Unique List 2 Columns

    You mean something like this?
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    This works great - thanks a lot! Is there a way to generate separate text strings for each error type?

    Quote Originally Posted by kalak View Post
    another
    Please Login or Register  to view this content.

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Generate Unique List 2 Columns

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

  21. #21
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Thanks - is there a way to generate separate text strings (msgboxes) for each error type?

  22. #22
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    unsure of the present status of this thread

    However regarding your
    "Thanks - is there a way to generate separate text strings (msgboxes) for each error type?"

    do you mean something like as given by the following code (for your opening post data)?
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    What is want is what kalak posted above but instead of having 1 text string that lists all unique combinations, i want to be able to generate separate text strings for each error type - separate message boxes for each error type. Can this be done?

    Please Login or Register  to view this content.

  24. #24
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    hmm ...

    consider

    suppose you run the following code using your data from your opening post

    for me, the code gives separate text strings for each error type on the worksheet in cells D2, D3 and D4.

    it also gives a single text string in one message box

    you can see, and compare, both these from the code output

    are you asking for three separate message boxes, one after the other so you can click OK for each one in succession?

    it's not any problem to do that (actually it is done in the code) although I don't see any purpose for it, so wonder if that is what you really do want
    Please Login or Register  to view this content.

  25. #25
    Registered User
    Join Date
    09-12-2012
    Location
    gemestio are
    MS-Off Ver
    Excel 2010
    Posts
    53

    Re: Generate Unique List 2 Columns

    Kalak - thanks a lot for all your help. I managed to tweak the code a bit and to generate what I needed. Just one thing, out of curiosity - in the following line:

    Please Login or Register  to view this content.
    Is there an easy way to generate only the list after ":""? I.e., the causes of error for each error type? I saw that the join(a(i).items joins both the error type and the causes of error, but is there a way to separate the causes of error in a text string?

    Thanks once again,

    D.

  26. #26
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Generate Unique List 2 Columns

    this?
    Please Login or Register  to view this content.

+ 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. Replies: 0
    Last Post: 02-12-2014, 08:22 AM
  2. Excel Function to Generate list of unique entries from multiple columns
    By ronnycool in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 06:15 PM
  3. [SOLVED] Generate Unique list
    By Cavinaar in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-27-2013, 03:03 AM
  4. Generate a list of unique code
    By luvul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2009, 04:40 AM
  5. Generate a unique number of list
    By Terence Chan in forum Excel General
    Replies: 3
    Last Post: 09-14-2005, 02:48 AM

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