+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    06-15-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question How to combine two columns with certain conditions?

    Hi all,

    I have a small but delicate problem, that I want to solve without using VBA. I have two pairs of data. The first pair consists of the "price" and "NR of sales" of items X and the second pair consists of the "price" and "NR in stock"of items X. The colums try to predict the number in stock and sales at at a certain market price.

    Now what I want to do is to merge both pairs into one pair of data with three columns, and apply the following conditions.
    -for every price there must be a "NR of sales" & "NR in stock"
    -when one of the other data sets does not have a price that the other pair has, then for "NR of Sales" it needs to fill in a "NR of sales" number from pair 1 with a price higher than the price in the new merged columns. For a "NR in stock" value this should be a lower number.

    The example should make this clear:

    Pair 1:

    Price;NR of Sales
    $18.00;50000
    $19.00;45000
    $20.00;37000
    $24.00;32000
    $28.00;26000
    $32.00;25000

    Price;NR in Stock
    $31.00;45000
    $29.00;36000
    $28.00;28000
    $27.00;22000
    $24.00;16000
    $19.00;12000
    $10.00;5000

    Now I want to merge these two pairs, and the merged pair should look like the following:
    PRICE;NR of SALES; NR in Stock
    $10.00;50000;5000
    $18.00;50000;5000
    $19.00;45000;12000
    $20.00;37000;16000
    $24.00;32000;16000
    $27.00;26000;22000
    $28.00;26000;28000
    $29.00;25000;36000
    $31.00;25000;45000
    $32.00;25000;45000

    I also attached a spreadsheet for your convenience,

    Thanks!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    04-25-2009
    Location
    Mo.
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: How to combine two columns with certain conditions?

    Takes a while to type but is Very fast and simple if you read my way of compairing. You can easily do this in many columns if I follow your questions correctly.

    First click a blank cell in a blank column, now hit the field plus on the 10 key, now click one of the cells with the information in it that you need such as the price, now hit minus on the 10 key or asteric or / for multiply or devide or plus key located next to the backspace key to add, next click the cell you want to compair price with and hit enter. once done you should have the difference in price minus price or price devided by price in the first blank cell you clicked in. Now click on that cell and copy, then black out the whole column there and click paste, excel compairs them all for you at once.

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,222

    Re: How to combine two columns with certain conditions?

    Ok, your tables needed the missing ZERO values, and they needed to both be in ascending order, and with that, simple worksheet functions do the rest. Index/Match...

    Have a look.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    06-15-2009
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question Re: How to combine two columns with certain conditions?

    Excellent that seems to work. Now I also need the price column in the Pairs
    Merged automated, grabbing its data from the price range in PAIR 1 and Pair 2, any idea how to do this.

    I tried to copy and sorted the data ascending, but I get double prices (e.g. $19.00) that do not belong there, and only need to be single.

    Thanks

  5. #5
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    18,222

    Re: How to combine two columns with certain conditions?

    Please post your new needs / issues in a viewable document so my weak old brain can fathom it more clearly. Thanks.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

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.2.0