+ Reply to Thread
Results 1 to 15 of 15

Find unique field in one column and extract data in previous columns

  1. #1
    Registered User
    Join Date
    09-12-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    6

    Find unique field in one column and extract data in previous columns

    Hi
    I have invoices extracted on an excel sheet. There are around 4000 invoices. The invoice number (unique field) is in column F and the data i want to extract is in column D, starting 5 rows below the invoice nummber. The data to be extracted varies in quantum i.e. it spreads from to 2 to 10 rows below the invoice number. Please tell me a solution of finding the data through the invoice number, and displaying the data in column D.

    Thanks.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    Are you able to provide an example or fabricate one for us?

    I understand invoices can contain a lot of sensitive information, but you greatly increase your chances of receiving assistance if you're able to provide a work sample or at least make one up.

  3. #3
    Registered User
    Join Date
    09-12-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find unique field in one column and extract data in previous columns

    For Forum.xlsx

    Oh, should have done it earlier.

    I have attached the sample file. The data to find is highlighted in red, and the data to be extracted is highlighted in blue.

    Thanks.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    You highlighted a number of rows on your example.

    Are you still just targetting the dimensions in Column D for each invoice?

  5. #5
    Registered User
    Join Date
    09-12-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find unique field in one column and extract data in previous columns

    No the whole blue highlighted area (columns B to I). However, i think the formula would work column wise and that should be perfect. For instance, i will have to input a formula in one cell to extract column B data, then in the next cell to extract column C data and so on.

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    Almost done. This is difficult, pretty much at the limit of my abilities.

    I'm using MATCH to find what row the Invoice is on, using a dynamic range for the first relevant column, and search that column for the first occurence of "Product", after the first match of that invoice.

    On the bright side, I totally got to learn how to use INDIRECT which is something I've been meaning to educate myself on.

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    So far I have:

    L2 = invoice to match, M1 = Product

    =MATCH(L2,INDIRECT(CHAR(COLUMN(B1)+64)&(ROW(B1)+MATCH(M1,$I$1:$I$50000,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$50000)),0)

    This finds the first occurence of the word Product after a successful match to the invoice.

    Now I need a 5 minute break. Then I'll write a dynamic range formula for the Index and the rest will be copy and paste.


    Finished product will look something like:

    =INDEX(INDIRECT(CHAR(COLUMN(B1)+64)&(ROW(B1)+MATCH(M1,$I$1:$I$50000,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$50000)),MATCH(L2,INDIRECT(CHAR(COLUMN(B1)+64)&(ROW(B1)+MATCH(M1,$I$1:$I$50000,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$50000)),0)+ROW(A1))

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    I was close:

    =INDEX(INDIRECT("B"&(ROW(B1)+MATCH($H$2,$E$1:$E$30,0))&":"&CHAR(COLUMN(D1)+64)&ROW($B$4000)),MATCH(I2,INDIRECT(CHAR(COLUMN(B1)+64)&(ROW(B1)+MATCH($H$2,$E$1:$E$30,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$4000)),0)+1,COLUMN(A1))

    Now I just need to account for spaces between items, such as C18 for example. There's always a way.
    Last edited by daffodil11; 09-13-2013 at 04:09 PM.

  9. #9
    Registered User
    Join Date
    05-15-2013
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Find unique field in one column and extract data in previous columns

    I put the solution and result in another sheet"solution" see if this is what you needed
    Attached Files Attached Files

  10. #10
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    Just about done.

    See the attached. This formula is in 03, and then copied and pasted across 8 columns and down 10 rows.

    =IF(INDEX(INDIRECT("B"&(1+MATCH($N$2,$I$1:$I$50000,0))&":"&CHAR(COLUMN(D1)+64)&ROW($B$4000)),MATCH(O$2,INDIRECT(CHAR(COLUMN(B1)+64)&(1+MATCH($N$2,$I$1:$I$50000,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$50000)),0)+ROW(A1),COLUMN(A1))=0,"",INDEX(INDIRECT("B"&(1+MATCH($N$2,$I$1:$I$50000,0))&":"&CHAR(COLUMN(D1)+64)&ROW($B$4000)),MATCH(O$2,INDIRECT(CHAR(COLUMN(B1)+64)&(1+MATCH($N$2,$I$1:$I$50000,0))&":"&CHAR(COLUMN(B1)+64)&ROW($B$50000)),0)+ROW(A1),COLUMN(A1)))


    I just need to work in another dynamic range for the end range, so that you don't get garbage after any instance of Total Quantity in Column D.

    INDIRECT is hard.xlsx

  11. #11
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    I am stumped. I was unable to replace the end of the first range's number value with:

    (MATCH("Total Quantity",INDIRECT(CHAR(COLUMN($D1)+64)&(1+MATCH($N$2,$I$1:$I$50000,0))&":"&CHAR(COLUMN($D1)+64)&ROW($B$4000)),0))

    althought I got it to work fine in my own example.

  12. #12
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Find unique field in one column and extract data in previous columns

    Hello Waqas,

    I have use some helper columns in output sheet to avoid Array Formulas. If you wish, you can move them in a separate sheet & hide the sheet.

    Invoice No. will automatically extract & give them in validation list in E2. Just copy formula down as needed.

    See the attached.
    Attached Files Attached Files
    Last edited by Haseeb Avarakkan; 09-13-2013 at 09:12 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  13. #13
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Find unique field in one column and extract data in previous columns

    I have no idea how you did what you did, but it's awesome.

  14. #14
    Registered User
    Join Date
    09-12-2013
    Location
    Pakistan
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Find unique field in one column and extract data in previous columns

    Thank you everyone! u guys are amazing in here! freaking mind blowing..
    yeah daffodil11, amazing job haseeb ... ur solution worked perfectly! nice..

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Find unique field in one column and extract data in previous columns

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Replies: 8
    Last Post: 09-12-2013, 09:17 AM
  2. Extract unique data from rows to columns
    By CherryBlossom in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-19-2013, 05:12 AM
  3. Extract data basesd on a unique column to new sheets
    By ahad_bwp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 12:40 AM
  4. Find unique number in columns and return column title
    By mkvassh in forum Excel General
    Replies: 3
    Last Post: 10-21-2010, 10:29 AM
  5. find matching value and return data from previous column
    By mheinmiller in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2009, 12:36 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