+ Reply to Thread
Results 1 to 24 of 24

Using lookup to find the 1st, 2nd, 3rd and 4th value

  1. #1
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Using lookup to find the 1st, 2nd, 3rd and 4th value

    In this spreadsheet, I have one worksheet with a list of customers and another worksheet with a list of their orders. Sheet 1 has the customer name in one row, sheet 2 has a separate row for each order the customer has placed. I want to return all the order details from sheet 2 into sheet 1, but have them on one row. Columns B-I in sheet 1 are where I would like this to be populated in.

    Thank you in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Try this:

    B2=IFERROR(INDEX(Sheet2!$B:$C,SMALL(IF(Sheet2!$A$2:$A$11=Sheet1!$A2,ROW(Sheet2!$A$2:$A$11),""),(COLUMN()-COLUMN($B$1))/2+1),MOD(COLUMN()-COLUMN($B$1),2)+1),"")

    Copy across and down.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Another option in B2 dragged down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,292

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Formula
    price
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Subject
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    I'll tried the solution of Nick, but 4 prices stays empty.
    Am I doing something wrong?
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by nick.williams View Post
    Try this:

    B2=IFERROR(INDEX(Sheet2!$B:$C,SMALL(IF(Sheet2!$A$2:$A$11=Sheet1!$A2,ROW(Sheet2!$A$2:$A$11),""),(COLUMN()-COLUMN($B$1))/2+1),MOD(COLUMN()-COLUMN($B$1),2)+1),"")

    Copy across and down.
    Can't get this to work, are you entering this into cell B2 in sheet 1? If so, don't formulas need to start with '='?

  7. #7
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by Fluff13 View Post
    Another option in B2 dragged down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This works great, just trying to see how to adapt it to the sheet I'm using (which I can't share for data protection reasons). Assuming the columns are in the same order, which parts do you think I need to change? I've tried changing the sheet names, but still can't get it to work.

    Thanks so much.

  8. #8
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by Czeslaw View Post
    Formula
    price
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Subject
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This works in this scenario, but if I were to amend the prices so two products have the same price it no longer appears to work. In the real sheet I'm using, there will be different products with the same price.

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Assuming the columns are in the same order, which parts do you think I need to change?
    I've no idea without seeing the actual sheet. Can you post something more realistic of your actual data.

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by HansDouwe View Post
    Am I doing something wrong?
    Nope, it's the formula

  11. #11
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    worksheet Or Tab name : Sheet1

    Cell B2 formula , Drag down and across

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by HansDouwe View Post
    I'll tried the solution of Nick, but 4 prices stays empty.
    Am I doing something wrong?
    You're right, I missed a FLOOR that should have been there.

    =IFERROR(INDEX(Sheet2!$B:$C,SMALL(IF(Sheet2!$A$2:$A$11=Sheet1!$A2,ROW(Sheet2!$A$2:$A$11),""),FLOOR((COLUMN()-COLUMN($B$1))/2,1)+1),MOD(COLUMN()-COLUMN($B$1),2)+1),"")

  13. #13
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by Excel_apprentice View Post
    Can't get this to work, are you entering this into cell B2 in sheet 1? If so, don't formulas need to start with '='?
    Yes, enter into B2, don't type the B2 again. It had a small error, please see post 12.

  14. #14
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    worksheet Or Tab name : Sheet1

    Cell B2 formula , Drag down and across

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by Fluff13 View Post
    I've no idea without seeing the actual sheet. Can you post something more realistic of your actual data.
    I've changed the column order so it matches, just in case that was the problem.

  16. #16
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by nick.williams View Post
    You're right, I missed a FLOOR that should have been there.

    =IFERROR(INDEX(Sheet2!$B:$C,SMALL(IF(Sheet2!$A$2:$A$11=Sheet1!$A2,ROW(Sheet2!$A$2:$A$11),""),FLOOR((COLUMN()-COLUMN($B$1))/2,1)+1),MOD(COLUMN()-COLUMN($B$1),2)+1),"")
    Thank you for this. I've been unable to replicate it in the sheet with the real data and I'm hoping this is because the columns are in a different order. I'm not sure which bits to change to match it up other than the sheet names. Could you possibly take a look at this attached sheet and tweak the formula so it matches?

  17. #17
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by wk9128 View Post
    worksheet Or Tab name : Sheet1

    Cell B2 formula , Drag down and across

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thank you for this. I've been unable to replicate it in the sheet with the real data and I'm hoping this is because the columns are in a different order. I'm not sure which bits to change to match it up other than the sheet names. Could you possibly take a look at this attached sheet and tweak the formula so it matches?

  18. #18
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Yes, you'd just need to change the columns. So for your new sheet it would be:

    =IFERROR(INDEX(Sheet2!$I:$J,SMALL(IF(Sheet2!$U$2:$U$11=Sheet1!$A2,ROW(Sheet2!$U$2:$U$11),""),FLOOR((COLUMN()-COLUMN($E$1))/2,1)+1),MOD(COLUMN()-COLUMN($E$1),2)+1),"")

  19. #19
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Or a potentially more robust variation as it allows you to have the subjects and prices in columns that aren't next to each other:

    =LET(schools,Sheet2!$U$2:$U$11,subjects,Sheet2!$I$2:$I$11,prices,Sheet2!$J$2:$J$11,ref_cell,$E$1,IFERROR(INDEX(CHOOSE({1,2},subjects,prices),SMALL(IF(schools=$A2,ROW(schools)-MIN(ROW(schools))+1,""),FLOOR((COLUMN()-COLUMN(ref_cell))/2,1)+1),MOD(COLUMN()-COLUMN(ref_cell),2)+1),""))

    In this version you just need to set the ranges for your Sheet2 columns (coloured red) which are at the start of the formula, and also set a reference cell which should be in the first column where you want the output.

  20. #20
    Registered User
    Join Date
    04-16-2021
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    91

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by nick.williams View Post
    Yes, you'd just need to change the columns. So for your new sheet it would be:

    =IFERROR(INDEX(Sheet2!$I:$J,SMALL(IF(Sheet2!$U$2:$U$11=Sheet1!$A2,ROW(Sheet2!$U$2:$U$11),""),FLOOR((COLUMN()-COLUMN($E$1))/2,1)+1),MOD(COLUMN()-COLUMN($E$1),2)+1),"")
    Thanks. When I change the sheet names and try that in the real sheet I keep getting a pop up telling me to update values for the worksheet I'm looking up against. I've tried changing the sheet name and making sure there's no spaces, but that didn't fix it. A bit puzzling.

  21. #21
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  22. #22
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,408

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    ANS. POST#17

    worksheet Or Tab name : Sheet1

    Cell E2 formula , Drag down and across

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  23. #23
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,292

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Power Query
    Please Login or Register  to view this content.

  24. #24
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Using lookup to find the 1st, 2nd, 3rd and 4th value

    Quote Originally Posted by Excel_apprentice View Post
    Thanks. When I change the sheet names and try that in the real sheet I keep getting a pop up telling me to update values for the worksheet I'm looking up against. I've tried changing the sheet name and making sure there's no spaces, but that didn't fix it. A bit puzzling.
    I'm strugling to reproduce your problem. Is it in a different workbook rather than just a different sheet? I'm not sure if that might cause issues.

+ 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. [SOLVED] Find(/lookup) next value
    By henrikf1 in forum Excel Formulas & Functions
    Replies: 24
    Last Post: 07-25-2016, 07:08 PM
  2. [SOLVED] Lookup formula to find lowest value with variable lookup criteria
    By brharrii in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-27-2015, 03:00 AM
  3. Excel 2007 : Help with Find or Lookup
    By StevenP138 in forum Excel General
    Replies: 2
    Last Post: 04-26-2012, 09:48 AM
  4. Lookup & Find
    By suhabthan in forum Excel General
    Replies: 4
    Last Post: 03-05-2012, 09:03 PM
  5. Excel 2007 : lookup --> find next! need help!
    By nguyenthao_0642 in forum Excel General
    Replies: 13
    Last Post: 09-27-2011, 08:03 AM
  6. Search lookup array to find lookup value contained within text string
    By Cookstein2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-02-2011, 09:42 AM
  7. LOOKUP to find value that is not zero
    By cedarhill in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-17-2009, 01:27 PM

Tags for this Thread

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