+ Reply to Thread
Results 1 to 10 of 10

combining two pairs of columns

  1. #1
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    combining two pairs of columns

    I have four columns of results, columns A and B belong together (they are price and associated quantity) and columns C and D belong together (which are also a price and an associated quantity).
    Usually there will only be a result in columns A and B, or, columns C and D, but sometimes the results do appear in both A and B, and also C and D.
    If results appear in both A and B, and also C and D, then i want to take the results from A and B only.

    What im trying to do is combine the two sets of data (with a result in A and B taking preference to a result in C and D) so that i just have one set of results in columns E and F.
    Ive attached a workbook to what the result will look like in cols E and F
    Attached Files Attached Files
    Last edited by intothewild; 01-02-2013 at 05:16 PM.

  2. #2
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: combining two pairs of columns

    Hi there,

    Can you just go with these functions?
    E2: =if(isnull(A2); C2; A2)
    F2: =if(isnull(D2); B2; D2)

    and then copy them down.
    Or is there anything else to it?

    Regards,
    Rick

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: combining two pairs of columns

    In G2, drag it across and down

    =IF(COUNTA($A2:$B2)=0,C2,A2)

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,958

    Re: combining two pairs of columns

    Look at the attached. I put the formulas in G and H, but you just need to copy them into E and F
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: combining two pairs of columns

    Rick i got an error with yours.
    Jie, thanks that works.
    Alan, yours is tricky and im as clear as i need to be on it.
    Please Login or Register  to view this content.
    Can you explain it because i need to write it in VBA without the R1C1 refs that i get from the macro recorder:
    Please Login or Register  to view this content.
    Last edited by intothewild; 01-02-2013 at 05:46 PM.

  6. #6
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: combining two pairs of columns

    Quote Originally Posted by intothewild View Post
    Rick i got an error with yours.
    Sorry, always forget to write comma's in the formulas, my home version of excel uses ";" seperator in formulas :P
    My post should read:

    E2: =if(isnull(A2), C2, A2)
    F2: =if(isnull(D2), B2, D2)

  7. #7
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: combining two pairs of columns

    nope doent work either Rick, i tried commas too.

  8. #8
    Forum Contributor
    Join Date
    01-20-2012
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: combining two pairs of columns

    I see... I didn't mention yet, i also have the dutch version at home :P, so my guess was the dutch formula "isleeg" refers to "isnull".
    Just looked it op, turns out to translate as "isblank". The formula "isnull" doesn't even exists :P

    Try this:
    E2: =if(isblank(A2), C2, A2)
    F2: =if(isblank(D2), B2, D2)

  9. #9
    Forum Contributor
    Join Date
    06-29-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    122

    Re: combining two pairs of columns

    Quote Originally Posted by rkey View Post
    I see... I didn't mention yet, i also have the dutch version at home :P, so my guess was the dutch formula "isleeg" refers to "isnull".
    Just looked it op, turns out to translate as "isblank". The formula "isnull" doesn't even exists :P

    Try this:
    E2: =if(isblank(A2), C2, A2)
    F2: =if(isblank(D2), B2, D2)

    Thats works, cheers!
    Can you put Alans into English?

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,958

    Re: combining two pairs of columns

    If C2 is blank or if C2 and A2 are not blank, then use the value in A2. If the preceeding sentence is false, then use the value in C2.

    Alan

+ 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