+ Reply to Thread
Results 1 to 4 of 4

Concatenate 2 Dates Conditionally Using Another Cell

  1. #1
    Registered User
    Join Date
    09-19-2017
    Location
    Virginia, United States
    MS-Off Ver
    2010
    Posts
    2

    Concatenate 2 Dates Conditionally Using Another Cell

    Hello,

    I'm looking for a macro to concatentate the earliest date and the latest date in column A separated by "-", but only from the rows in which column B is the same. Additionally if the value in column B only appears once then just return the date from Column A.

    Column A Column B Column C
    9/16/2017 A 13 Sep - 16 Sep
    9/16/2017 B 12 Sep - 16 Sep
    9/15/2017 B 12 Sep - 16 Sep
    9/13/2017 A 13 Sep - 16 Sep
    9/13/2017 C 13 Sep
    9/13/2017 B 12 Sep - 16 Sep
    9/12/2017 B 12 Sep - 16 Sep

    Thanks in advanced for any help or advice,

    chiatbw

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: Concatenate 2 Dates Conditionally Using Another Cell

    Hello chiatbw,

    Welcome to the forum!

    Copy this formula into cell "C1"and drag it down as far as you need.

    =IF(B1<>"",IF(COUNTIF(B:B,B1)=1,TEXT(A1,"dd mmm"),TEXT(MIN(A:A),"dd mmm")&" - "&TEXT(MAX(A:A),"dd mmm")),"")
    Last edited by Leith Ross; 09-19-2017 at 02:12 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-19-2017
    Location
    Virginia, United States
    MS-Off Ver
    2010
    Posts
    2

    Re: Concatenate 2 Dates Conditionally Using Another Cell

    Leith,

    Thanks so much for the reply. I apologize for the table not being a table as it seems the spaces were removed from my "columns". Perhaps I should learn how to insert tables in this forum. I haven't tried your solution yet and please correct me if I'm wrong but....

    It looks like the (MIN) AND (MAX) search the entire column. I only want the min and max of dates from column A when the value in Column B is the same. So in the case above I want to return the min and max of all dates of rows/cells in column A where "specified value" is present in column B.

    Blessings,

    chiatbw

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Concatenate 2 Dates Conditionally Using Another Cell

    This is an array formula so use CTRL+SHIFT+ENTER to commit.

    C1: =TEXT(MIN(IF($B$1:$B$7=B1,$A$1:$A$7,FALSE)),"dd mmm") & IF(NOT(MIN(IF($B$1:$B$7=B1,$A$1:$A$7,FALSE))=MAX(IF($B$1:$B$7=B1,$A$1:$A$7,FALSE)))," - " & TEXT(MAX(IF($B$1:$B$7=B1,$A$1:$A$7,FALSE)),"dd mmm"),"")

    then copy down
    Cheers
    Andy
    www.andypope.info

+ 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: 1
    Last Post: 01-04-2017, 06:00 PM
  2. Replies: 1
    Last Post: 01-04-2017, 05:59 PM
  3. [SOLVED] conditionally concatenate values in second table
    By kammend in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-27-2016, 11:44 AM
  4. [SOLVED] How to concatenate mutiple rows and show it in a single Cell Conditionally
    By Kandavalli.Kiran in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2015, 04:48 PM
  5. [SOLVED] Conditionally format cell based on dates within a number of days apart
    By mjy58 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-24-2013, 06:01 PM
  6. [SOLVED] Concatenate list of dates into one cell without duplicates
    By rachel.dudley in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-14-2013, 07:38 AM
  7. how do i concatenate conditionally formatted cells in excel
    By Sandwiches2 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-13-2006, 09:45 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