+ Reply to Thread
Results 1 to 5 of 5

Using vlookup for non-unique first and last values

Hybrid View

  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 02:18 AM. Reason: formatting

  2. #2
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    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 02: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 Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    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?

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

    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
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ 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.6.0 RC 1