+ Reply to Thread
Results 1 to 11 of 11

Concatenate list of dates into one cell without duplicates

  1. #1
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Angry Concatenate list of dates into one cell without duplicates

    I wish to concatenate a list of dates in a range (C3:C9) into another cell (say L40) without duplicates so for example my list of dates is:

    06/03/2013
    06/03/2013
    06/03/2013
    08/03/2013
    08/03/2013
    08/03/2013
    09/03/2013

    The output in L40 would be:

    06/03/2013, 08/03/2013, 09/03/2013


    I currently have a working solution in that I use a public function (shown below):

    Please Login or Register  to view this content.
    And then call the function in L40 like so:

    Please Login or Register  to view this content.

    But for some reason one of my colleagues computers does not like this and highlights the word Trim in the VBA code.

    So I'm either looking for an alternative or anyone to shed light on why his Excel would not like the word Trim.

    Thanks if anyone can help.

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

    Re: Concatenate list of dates into one cell without duplicates

    That function has a bug...
    If the values like
    12
    2
    12
    30
    3
    20
    10
    It will miss 2 and 3 due to nature of Instr function....

    try

    =ConcatUniq(C3:C9,", ")
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Concatenate list of dates into one cell without duplicates

    Hi Jindon,

    That seems to work but it displays the dates as numbers e.g. 41340, 41341. I have tried formatting the cell but it does not change.

    Is there anyway of showing them in date format using this method?

    Thanks for your help.

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

    Re: Concatenate list of dates into one cell without duplicates

    Hummmm, then
    Please Login or Register  to view this content.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Concatenate list of dates into one cell without duplicates

    I can't see why it should fail on Trim() on any machine.

    Assuming you apply the function to a range that only contains valid dates or blanks this should work, by negating the need to use Trim().
    Please Login or Register  to view this content.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Concatenate list of dates into one cell without duplicates

    Hi Jindon,

    That works great, but is there anyway of getting rid of the comma after the last date?

    Marcol, I have Googled this and it seems to be a common problem with trim, left, right, etc. functions. I found that if you go into References there will often be one that states MISSING that is now ticked after the problem occurs. If you untick it and try again, it works, but once you've closed and re-opened the workbook, the problem occurs again.

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

    Re: Concatenate list of dates into one cell without duplicates

    If you have blank(s) within the range then
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Concatenate list of dates into one cell without duplicates

    Great, thanks fingers crossed this works ok on my colleagues computer.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Concatenate list of dates into one cell without duplicates

    Quote Originally Posted by rachel.dudley View Post
    ...
    Marcol, I have Googled this and it seems to be a common problem with trim, left, right, etc. functions. I found that if you go into References there will often be one that states MISSING that is now ticked after the problem occurs. If you untick it and try again, it works, but once you've closed and re-opened the workbook, the problem occurs again.
    I wasn't aware of that problem.
    The solution you have found seems to be the answer, but if it shows again when you re-open the workbook again, then we have a problem.

    1/. What version of Excel is your colleague using & does he/she have the last service pack installed?

    2/. Try using either of these lines if you need to use Trim()
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Concatenate list of dates into one cell without duplicates

    The Forum is hanging yet again and choosing to double post on recovery.

    See post #9
    Last edited by Marcol; 03-14-2013 at 07:35 AM. Reason: message deleted, Forum error

  11. #11
    Registered User
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Concatenate list of dates into one cell without duplicates

    Hi Marcol,

    I just gave it a quick Google and saw at least 5 pages of results of people posting the same type of question to forums etc.

    My colleague uses Excel 2007 and we installed the latest SP last week when we were trying to solve the problem.

    I will keep the lines of code you have provided to hand just in case, I did try vba.Trim because someone on one of the various forums recommended it but my colleague didn't have a chance to try that before I found the different solutions from Jindon & yourself.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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