+ Reply to Thread
Results 1 to 8 of 8

Make repetitive IF formula more concise?

  1. #1
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Make repetitive IF formula more concise?

    Hello

    I use this formula in many of my spreadsheets for last/first/middle name:


    =CHAR(10)&
    UPPER(IF(C4="","",C4&", "&C5&IF(C6="",""," "&C6)&REPT(CHAR(10),2))
    &IF(D4="","",D4&", "&D5&IF(D6="",""," "&D6)&REPT(CHAR(10),2))
    &IF(E4="","",E4&", "&E5&IF(E6="",""," "&E6)&REPT(CHAR(10),2))
    &IF(F4="","",F4&", "&F5&IF(F6="",""," "&F6)&REPT(CHAR(10),2))
    &IF(G4="","",G4&", "&G5&IF(G6="",""," "&G6)&REPT(CHAR(10),2))
    &IF(H4="","",H4&", "&H5&IF(H6="",""," "&H6)&REPT(CHAR(10),2))
    &IF(I4="","",I4&", "&I5&IF(I6="",""," "&I6)&REPT(CHAR(10),2))
    &IF(J4="","",J4&", "&J5&IF(J6="",""," "&J6)&REPT(CHAR(10),2))
    &IF(K4="","",K4&", "&K5&IF(K6="",""," "&K6)&REPT(CHAR(10),2)))


    Is there a more concise formula for this since it is so repetitive?

    Thanks for any help!

    VR/Lost

  2. #2
    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: Make repetitive IF formula more concise?

    Hi leaning

    I, for one, am finding it difficult to understand what your formula is meant to do.

    You would do best to post a sample workbook showing your Sheet Layout and Before and After examples.

    It should clearly illustrate your problem and not contain any sensitive data.

    Cheers

  3. #3
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Make repetitive IF formula more concise?

    Marcol,

    Cleaning a worksheet will take some time, but maybe I can explain better.

    Say you had a group of people (nine people max) who you were going to send a letter to.

    So depending on what names where on those cells determines who is on the "To:
    block of the letter.

    So the formula for the actual "To:" block would be:

    ="To: "& UPPER(IF(C4="","",C4&", "&C5&IF(C6="",""," "&C6)&REPT(CHAR(10),2))
    &IF(D4="","",D4&", "&D5&IF(D6="",""," "&D6)&REPT(CHAR(10),2))
    &IF(E4="","",E4&", "&E5&IF(E6="",""," "&E6)&REPT(CHAR(10),2))
    ....

    The output would be:

    To: SMITH, JOHN RICHARD

    JONES, MICHAEL WILLIAM

    JACKSON, SAMUEL L.

    Since only three names were entered, that ends the formula. More names = a longer list.

    I was wondering if there was a trick to squash the formula down since it looks at C4,C5,C6, then E4,E5,E6, then F4,F5,F6, etc.

    HTH!

    VR/Lost

  4. #4
    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: Make repetitive IF formula more concise?

    Hmm?
    It would appear that your names list/block has a rather unconventional layout.
    Why are Surname, First Name, and Middle Name in columns and not rows?
    Why would you have empty columns in the "Block"?

    Am I reading this correctly?
    Last edited by Marcol; 03-17-2011 at 12:33 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Make repetitive IF formula more concise?

    Marcol,

    Yes.

    Person 1 LName is in C4, FName in C5, MName plus Suffix (if any) in C6.
    Person 2 LName in D4, FName in D5, MName in D6
    Person 3 LName in E4, FName in E5, MName in E6, etc.
    .
    .
    .
    Person 9 LName in K4, FName in K5, MName in K6.

    The concatenating/IF formula is in L15.

    You would have an empty block if the person didn't have a middle name, or maybe didn't have a last name (Cher, Madonna, etc.).

    The formula I am using works; I just am curious whether there is a range or looping or something formula that would work that isn't so wordy.

    HTH!

    VR/Lost

  6. #6
    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: Make repetitive IF formula more concise?

    Unfortunately there is no array capability when concatenating that I know of, the only way is to use VBa to create an UDF.

    Would this be acceptable?
    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.

  7. #7
    Valued Forum Contributor
    Join Date
    02-26-2010
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2003/2007/2010/2016
    Posts
    432

    Re: Make repetitive IF formula more concise?

    Marcol,

    I think a UDF would be more complicated and more work than a long concatenate equation.

    This'll work.

    I appreciate your help in looking at this and seeing if there was a better way.

    Thanks!

    VR/Lost

  8. #8
    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: Make repetitive IF formula more concise?

    Okay,
    Try this, it might not be what you are after, but it is the best I can offer with the information given

    In C7
    Please Login or Register  to view this content.
    Drag/Fill across Left to K7 (Total 9 columns)

    In A1
    Please Login or Register  to view this content.
    If you need more than 9 names, Drag K7 further left, add to the concatenation in A1 and change the COUNTA range.

    If you don't want the last blank line in A1 use
    Please Login or Register  to view this content.
    To change case, change UPPER to LOWER or PROPER.

    Hope this helps

    Change or delete any cell in the range C4:K6 to see the changes in A1
    Attached Files Attached Files
    Last edited by Marcol; 03-18-2011 at 06:03 AM. Reason: Amended to allow for empty table

+ 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