+ Reply to Thread
Results 1 to 10 of 10

formula to copy value of any value in given row

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    formula to copy value of any value in given row

    I have 4 columns, B through E. I already have programming in place that for the first 3 columns, ($B:$D), only 1 of the 3 cells will contain a value and the other 2 cells will be blank (there is no possibility of a value in more than 1 of the cells in the first 3 columns of any given row). I need a formula in column E to copy the value that is in the same row, regardless if it is in column B, C, or column D.

    Also, it is possible that all 3 of the first 3 columns may not contain a value (all 3 blank), which in that case, I may decide that the column E value for that row may need to contain an value to be decided later as I develop the spreadsheet.

    I could probably do a highly nested IF statement... but maybe there's something simpler?

  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,946

    Re: formula to copy value of any value in given row

    If they are values, maybe...
    =max(B2:D2)
    or even =SUM(B2:D2)

    if none have a value, maybe...
    =if(count(B2:D2)=0,"your comment",max(B2:D2))
    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 Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: formula to copy value of any value in given row

    Hmmm.... as I copy the formula down column E (about 30 rows), all of those rows will be numeric EXCEPT the first row, which will be either numeric or a text value, depending on which column it is in. So I think I'm on the right track with your help, but will need to experiment with it a bit. Further suggestions are welcome while I do, of course

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: formula to copy value of any value in given row

    In E2
    =IF(COUNT(B2:D2)>0,INDEX(B2:D2,MATCH(9^99, B2:D2)),"")

    The issue comes with this statement
    Also, it is possible that all 3 of the first 3 columns may not contain a value (all 3 blank), which in that case, I may decide that the column E value for that row may need to contain an value to be decided later as I develop the spreadsheet.
    Are you going to modify the formula at that time? If you input data into that cell, the formula will be gone.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: formula to copy value of any value in given row

    It's a little messy, but I'm thinking I could do something like E1=B1, IF...B1 ISBLANK, then E1=C1, IF C1 ISBLANK, then E1=D1, IF D1 ISBLANK, then "[my comment]"

    ...but need some help with the syntax! Does that look doable?

  6. #6
    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,946

    Re: formula to copy value of any value in given row

    You have been offered a working solution, why not use that?

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: formula to copy value of any value in given row

    I think it doesn't work for him because sometimes he has text. Is that correct?

    =IF(B1<>"", B1,IF(C1<>"",C1, IF(D1<>"", D1, "Comment")))

  8. #8
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: formula to copy value of any value in given row

    Yes... @FDibbins would work except for the 1st row. Which is a deal breaker... I need the text. Sorry.

    @ChemistB is correct... I'll try that code now...

  9. #9
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: formula to copy value of any value in given row

    @ChemistB... perfect!

    Much obliged, sir!

  10. #10
    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,946

    Re: formula to copy value of any value in given row

    Yes, I know mine didnt work because of the text, I meant ChemistB's suggestion

    Glad you got it resolved though

  11. #11
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: formula to copy value of any value in given row

    Oh, ok... thanks. I actually didn't see his post:

    Quote Originally Posted by ChemistB View Post
    In E2
    =IF(COUNT(B2:D2)>0,INDEX(B2:D2,MATCH(9^99, B2:D2)),"")
    until after my other post! But I got it! Thanks!

+ 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. Alter existing formula to copy specific cells in row instead of copy entire column
    By painterartist in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-02-2014, 12:42 PM
  2. Replies: 3
    Last Post: 01-30-2013, 04:32 PM
  3. Copy Multi Formula and then freeze cell refs before second copy
    By Trig79 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-23-2009, 07:53 AM
  4. Copy Formula:copy the exact same formula in one column
    By Leprechaun in forum Excel General
    Replies: 1
    Last Post: 12-11-2006, 07:46 PM
  5. [SOLVED] Copy/Paste how to avoid the copy of formula cells w/o calc values
    By Dennis in forum Excel General
    Replies: 10
    Last Post: 03-02-2006, 06:50 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