+ Reply to Thread
Results 1 to 6 of 6

Formula to write multiple values to a cell based on value of other cells

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Formula to write multiple values to a cell based on value of other cells

    Hi,

    I've got a bit of a tricky problem I'm trying to work out. To be honest, I'm not even sure if it can be accomplished with a formula, but I'm sure someone in here can tell me.

    I've got a spreadsheet with 2 columns, named Col1 and Col2. Some of the cells in these columns contain values, and others don't. I want to write a formula which will look across the row and see whether Col1 and/or Col2 on that row are empty or not. If one or both of the cells in that row contains data, I want to write the column name that contains data into a 3rd cell. I hope that makes sense.

    I've tried using the following formula, which works fine, but it breaks as soon as I try to extend it to the other column.
    Please Login or Register  to view this content.
    Any ideas?

    Thanks!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Formula to write multiple values to a cell based on value of other cells

    if you just want 1 of the headings shown if both have an entry, use this...
    =IF(F3<>"","Column1 Heading",IF(G3<>"","Column2 heading",""))

    if you want both headings shown if both contain an entry, use this instead...
    =IF(AND(F3<>"",G3<>""),"Column1 heading"&" & "&"Column2 heading",IF(F3<>"","Column1 Heading",IF(G3<>"","Column2 heading","")))

    adjust references as needed

    edit: sorry, you obviously need to replace "Column1 Heading" with either the real heading name, or an aobsolute reference to it
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Formula to write multiple values to a cell based on value of other cells

    you could use something like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Adjust Ranges for your data

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  4. #4
    Registered User
    Join Date
    11-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Formula to write multiple values to a cell based on value of other cells

    Thanks very much for the reply FDibbins

    The 2nd scenario is what I wanted, I think. Would there be a way to avoid specifying both column names if both columns contain data, and just run through the columns individually and append the values into the "target" cell?

    The reason I ask is because if I were to expand the table to have 3 columns, the formula would have to change to manually specify options for Col1+Col2+Col3, Col1+Col3, Col1+Col2, etc.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Formula to write multiple values to a cell based on value of other cells

    Quote Originally Posted by FDibbins View Post
    edit: sorry, you obviously need to replace "Column1 Heading" with either the real heading name, or an absolute reference to it
    eg A$1 or B$1

  6. #6
    Registered User
    Join Date
    11-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Formula to write multiple values to a cell based on value of other cells

    Thanks FDibbins and dredwolf for your replies. Neither of them quite worked 100%, but someone else gave me a formula which did work, so I'll post it here in case someone is looking for something similar.

    Please Login or Register  to view this content.

+ 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