+ Reply to Thread
Results 1 to 12 of 12

IF Condition: two cells with dates and concatenation of corresponding 2 text cells

  1. #1
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Hello All,

    I'm trying to automate an excel sheet. Sheet1 contains 4 columns and n rows.
    4 Columns = A, B, C, D. Columns A and B have data(text) in them. Columns C and D have dates in them.
    D cell can be empty without a date but C wont. Now the requirement goes this way:

    If D has a date, Concatenate A and B and paste the data under Column of corresponding month(current year)
    Else
    C's date, consider it, concatenate A and B and paste the data under Column of the month(current year).

    This is the requirement. Any help appreciated.

    Regards,
    D
    A B C D
    Data with text Data With Text dd/mm/yy dd/mm/yy(this column will be empty most of the times)
    result:
    Jan Feb Mar Apr
    Concatenated data of Cells A and B with their C/D dates falling under Jan/2013 Concatenated data of Cells A and B with their C/D dates falling under Feb/2013 Concatenated data of Cells A and B with their C/D dates falling under Mar/2013 Concatenated data of Cells A and B with their C/D dates falling under Apr/2013

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Something like the attached, maybe?
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    That's almost close Andrew. The current code is only working for horizontal while I am trying to look at columnD and then ColumnC, once confirmed: adding A and B. Could it be possible to use Index to obtain the dates, match to match the current month and year and then concatenate A and B cells.
    Please let me know, if it can be doable?!
    Many Thanks

  4. #4
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    I am trying to use Index and match functions.. I have come closer to looking at the date from one row and concatenate data of corresponding cells. Stuck at having two cells dates to go through..

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Can you post an example workbook, please (press the 'Go advanced' button and then the paperclip icon), because I'm really not sure what you're trying to achieve.

  6. #6
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Concatenate by date.xlsx

    Please find the attached file to this mail.
    I have added months to the same file (to the right of the months you concatenate) you have sent me and have added data to the result set. Please do help, when you can.

    Regards,
    Krish

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    OK, I cheated and added a helper column (column E) with the following formula:

    =IF(D2<>"",D2,C2)

    Then, in the first row of the January column I went with:

    =IF(ROW(A1)>SUMPRODUCT(--(TEXT($E$2:$E$15,"mmm")=T$1),--($E$2:$E$15<>"")),"",INDEX($A:$A,SMALL(IF(TEXT($E$2:$E$15,"mmm")=T$1,ROW($E$2:$E$15)),ROW(A1))) & INDEX($B:$B,SMALL(IF(TEXT($E$2:$E$15,"mmm")=T$1,ROW($E$2:$E$15)),ROW(A1))))

    This is an array formula and must be entered with Ctrl-Shift-Enter, not just enter. Once entered it can be copied across and down.

    Is that what you were after?

  8. #8
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Hi Andrew, Thanks a lot for the help. The dates should be calculated for current year and if they are in any other year, the particular column be omitted. I've run the code and its working fine. I am now interested in keeping it to current year. Any help appreciated. Many Thanks.

  9. #9
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Try changing the formula in column E to:

    =IF(AND(D2<>"",(YEAR(D2)=YEAR(NOW())),D2,AND(C2<>"",(YEAR(C2)=YEAR(NOW())),C2,"")

  10. #10
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Andrew, the formula in column E is coming up with errors.. did we miss any parenthesis?

  11. #11
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    Probably Give this one a go:

    =IF(AND(D2<>"",YEAR(D2)=YEAR(NOW())),D2,IF(AND(C2<>"",YEAR(C2)=YEAR(NOW())),C2,""))

  12. #12
    Registered User
    Join Date
    01-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: IF Condition: two cells with dates and concatenation of corresponding 2 text cells

    We made it Andrew. I mean, you made it. Many Thanks for your help. Keep supporting and do keep in touch.

    Regards,
    Krish
    Last edited by desibird; 02-25-2013 at 10:48 AM.

+ 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