+ Reply to Thread
Results 1 to 5 of 5

Thread: Using vlookup for non-unique first and last values

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Pune, India
    MS-Off Ver
    Excel 2007
    Posts
    2

    Using vlookup for non-unique first and last values

    Hi, I have data in the form
    Date Bill No.
    20 Nov, 11 125
    20 Nov, 11 126
    20 Nov, 11 127
    20 Nov, 11 128
    21 Nov, 11 129
    21 Nov, 11 130
    21 Nov, 11 131

    Usually the bill numbers are in ascending order, but sometimes, there may be one missing (cancelled transaction, etc.)
    Now I want to make a daily report which tells me how much business was done in a day (which bill numbers were done in a day).

    The format is something like:
    Date From Bill No. To Bill No.
    20 Nov,11 125 128
    21 Nov,11 129 131

    What formula can I use for the fields "from bill no." and "to bill no."?
    vlookup helps with the "from" one. No idea for the "to" one. Any suggestions??
    Last edited by siddhu666; 11-28-2011 at 01:18 AM. Reason: formatting

  2. #2
    Forum Guru darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Colorado, US
    MS-Off Ver
    2007
    Posts
    2,170

    Re: Using vlookup for non-unique first and last values

    Say your data is in A1:B30 and your table below is in D1:F10. F1 and down can have =Index(B:B,Match(D2,A:A,0)-1). This works if they are indeed in order (you can easily use sort for this). Alternatively, you can use =SUMPRODUCT(MAX((B$1:B$30)*(A$1:A$30=D1))). That will work if they are out of order.
    Last edited by darkyam; 11-28-2011 at 01:31 AM.
    Life is about perseverance. Remember: today's mighty oak tree is just yesterday's nut that held its ground.

    If you like a post, please rate it with the scales icon (top right).
    If you feel really indebted, please consider a donation to charity, such as Feed the Children or Habitat for Humanity.

  3. #3
    Registered User
    Join Date
    11-28-2011
    Location
    Pune, India
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Using vlookup for non-unique first and last values

    Quote Originally Posted by darkyam View Post
    Say your data is in A1:B30 and your table below is in D1:F10. F1 and down can have =Index(B:B,Match(D2,A:A,0)-1). This works if they are indeed in order (you can easily use sort for this). Alternatively, you can use =SUMPRODUCT(MAX((B$1:B$30)*(A$1:A$30=D1))). That will work if they are out of order.
    Hey darkyam,
    The data is in ascending date wise order. The formula is somehow showing the smallest bill no. of the next date, and not the highest number of the current date. Any idea?

  4. #4
    Forum Guru darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Colorado, US
    MS-Off Ver
    2007
    Posts
    2,170

    Re: Using vlookup for non-unique first and last values

    That shouldn't be the case with either formula. Any chance of posting a dummy workbook?
    Life is about perseverance. Remember: today's mighty oak tree is just yesterday's nut that held its ground.

    If you like a post, please rate it with the scales icon (top right).
    If you feel really indebted, please consider a donation to charity, such as Feed the Children or Habitat for Humanity.

  5. #5
    Valued Forum Contributor Haseeb A's Avatar
    Join Date
    05-24-2011
    Location
    India | Kwt
    MS-Off Ver
    2007
    Posts
    1,453

    Re: Using vlookup for non-unique first and last values

    Hello Siddhu,

    Use Pivot table & use MIN & MAX values. or use Array Formula.

    See attached
    Attached Files Attached Files
    HTH; Haseeb

    If your problem is solved, please say so clearly, and mark your thread as Solved:
    Forum Rules & How to Mark a thread as SOLVED

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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