+ Reply to Thread
Results 1 to 10 of 10

Concatenate formula including only cells that contain value

  1. #1
    Registered User
    Join Date
    07-10-2015
    Location
    San Jose, California
    MS-Off Ver
    2007
    Posts
    4

    Concatenate formula including only cells that contain value

    Hi everyone, I am trying to use excel to store my patients findings, and to create a report. A sort of very cheap and limited electronic health record.

    To do that I am using a table with multiple drop lists to input the findings, and the "concatenate" function to create the report. I would like to include in the concatenate formula only the cells that have a value, and ignore the ones that have no finding.

    For example:
    example.jpg


    The formula would be: =CONCATENATE("Inspection revealed ",A2," of the head, ",B2," of the neck, ",C2," of the knees, ",D2," of the feet.")

    Result: Inspection revealed anterior head carriage of the head, hyperlordosis of the neck, of the knees, increased Fick's angle of the feet.

    In this case I would like to ignore the "knees" part of the formula. I hope it makes any sense. Any suggestions?

    Thanks
    Last edited by giginho; 07-11-2015 at 02:59 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Concatenate formula including only cells that contain value

    So, what do you want in the case of knees - any reference to kness left out entirely, or what?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    07-10-2015
    Location
    San Jose, California
    MS-Off Ver
    2007
    Posts
    4

    Re: Concatenate formula including only cells that contain value

    Thanks for the immadiate response!

    It would be nice to be able to input something like for example "knees valgus angle appears within normal limits" or even ignore it completely.

  4. #4
    Registered User
    Join Date
    02-28-2015
    Location
    Tennessee, USA
    MS-Off Ver
    2010
    Posts
    25

    Re: Concatenate formula including only cells that contain value

    Here is a solution (also attached), although not a very elegant one, using the formula:

    ="Inspection revealed " & IF(B1<>"",B1 &" of the " & LOWER(A1) &", ", "") & IF(B2<>"",B2 &" of the " & LOWER(A2) &", ", "")& IF(B3<>"",B3 &" of the " & LOWER(A3) &", ", "")& IF(B4<>"", "and " & B4 &" of the " & LOWER(A4) &".", "")

    which gives the output:

    Inspection revealed anterior translation of the head, hyperlordosis of the neck, and increased Fick's angle of the feet.

    The last statement of the formula has been slightly altered so it includes the word "and" and has a period at the end instead of a comma.

    Let me know if that works for you, if not I could try a different approach.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Concatenate formula including only cells that contain value

    ibt... if you think your effort was inelegant, I won't embarass myself by posting the multi-line monster that I have in front of me.

  6. #6
    Registered User
    Join Date
    07-10-2015
    Location
    San Jose, California
    MS-Off Ver
    2007
    Posts
    4

    Re: Concatenate formula including only cells that contain value

    Thank you ibt, it works perfectly for the example but I think it wouldn't be very easy for me to apply your solution to the larger tables that I am using. I am a real newbie.

    Can I use any IF function inside the concatenate formula? For example, if blank then use the content of another cell, or if blank, ignore it.
    Last edited by giginho; 07-11-2015 at 12:30 PM.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Concatenate formula including only cells that contain value

    That was the way I was going, but it was truly horrible. To be honest, I think you'd be better served by a VBA solution (as Excel's concatenate functionality is a tad limited). However, I'm a VBA newbie, so I'm out...

  8. #8
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Concatenate formula including only cells that contain value

    Quote Originally Posted by Glenn Kennedy View Post
    However, I'm a VBA newbie, so I'm out...
    Really??

    However try my solution....
    Attached Files Attached Files
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  9. #9
    Registered User
    Join Date
    07-10-2015
    Location
    San Jose, California
    MS-Off Ver
    2007
    Posts
    4

    Re: Concatenate formula including only cells that contain value

    Thank you sourahg98 but I finally found a solution with the input of ibt.

    This following formula seems to work and is exactly what I was looking for..

    =CONCATENATE("Inspection revealed "&IF(A1<>"",A1&" of the head, ","") &IF(B2<>"",B2&" of the cervical spine, ",""))

    Thanks ibt!

  10. #10
    Registered User
    Join Date
    02-28-2015
    Location
    Tennessee, USA
    MS-Off Ver
    2010
    Posts
    25

    Re: Concatenate formula including only cells that contain value

    Thanks, I noticed there is an error in my solution in the case that the last body part does not have an issue. But here it is in VBA (I am on the newer side using it).

    The code is:

    Please Login or Register  to view this content.
    Let me know if you have issues.
    Attached Files Attached Files

+ 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. only including non-empty cells in the formula
    By jveeken in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-21-2014, 04:43 AM
  2. [SOLVED] Cells including unwanted characters (search formula?)
    By letangerang58 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-10-2013, 02:28 PM
  3. Replies: 3
    Last Post: 10-11-2012, 02:11 PM
  4. [SOLVED] Concatenate including blank cells and cells with more than one word
    By Shadefalcon in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-26-2012, 05:12 PM
  5. [SOLVED] Including results of formula within concatenate function
    By trandle in forum Excel General
    Replies: 1
    Last Post: 09-23-2009, 05:39 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