+ Reply to Thread
Results 1 to 16 of 16

Formula to grab the next highest number

  1. #1
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Formula to grab the next highest number

    Excel Gods,

    I am in dire need of assistance.

    I have this particular spreadsheet with 9 columns: Policy#, Iss St, G Issue, Iss Year, Prem Collected, Claims Paid, Infct, Agent Level, and Agent number.

    Thing problem with this spreadsheet is that In column A, Policy #, there are duplicates. When there are duplicates it is because there was more than one agent who helps the policy.

    ***What I want is to get rid of all the duplicates, and... get the highest agent level after one.
    For example: Policy Number 3082695 has three rows with corresponding agent level # 1,3, and 7. I only want the row that has the three because it is the next highest level after 1.

    If a policy doesn't have a duplicate than, I want that policy regardless.

    4Q2013DiamondPartnerforExcel10302015.xlsx

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Formula to grab the next highest number

    I used a helper column to identify the records that matched your criteria. The formula used in the first worksheet J2 and filled down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I created a second worksheet called Extract and used the headers from the first worksheet.
    Enter this in A2 and fill across and down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    In the workbook, I also used a filter to show that the records could be filtered after applying the first formula.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Your formula worked for the most part, but for some policy numbers like, 3089319 or 3086707 (there are more), your formula picked up an agent level 1, which it isn't suppose to. THere are lower agent levels.

  4. #4
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Your formula worked for the most part, but for some policy numbers like (30893189 or 3086707), your formula picked up agent lvl #1, which it isnt suppose to. There are agent levels below it.

  5. #5
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Capture.JPG

    Here is an attached example.

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Formula to grab the next highest number

    I missed what you meant by the Agent Level.

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula to grab the next highest number

    That mean you need the second largest AND not 1?
    1,1,5 => pick 5?
    1,1,4,5=>pick 4?
    Quang PT

  8. #8
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Agent level is column H. What I want is the next highest number after 1. If there isn't a number after 1, then return 1. If the number doesn't have 1 (Like policy 3082617) then return whatever agent level is there.

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula to grab the next highest number

    Quote Originally Posted by TexasBobcat View Post
    What I want is the next highest number after 1.
    is confusing me.
    Could you write down few samples as per my post in #7?

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula to grab the next highest number

    =IF(IFERROR(LARGE(IF($A$2:$A$5064=A2,IF($H$2:$H$5064=1,"",$H$2:$H$5064),""),2),LARGE(IF($A$2:$A$5064=A2,IF($H$2:$H$5064=1,"",$H$2:$H$5064),""),1))=H2,I2,"")

    Ctrl-shift-enter

    Does it work?

  11. #11
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    WHere should the formula you just gave me go?

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula to grab the next highest number

    Quote Originally Posted by TexasBobcat View Post
    WHere should the formula you just gave me go?
    paste into J2, confirmed with Ctrl-shift-enter, then drag down.

  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Formula to grab the next highest number

    In trying to solve the agent level, I came up against the situation where there were two agents of the same level and same policy. This either caused a double entry or caused an error to kill the whole thing. In addition when I thought that I had it beat, I was getting oddities with other policies of two agents.....grrr.

    I think that this will fix the problem...as far as I can determine.
    Enter in J2 of the first worksheet and fill down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

  14. #14
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Newdoverman,

    Your formula works great for the most part, but the thing is in the first worksheet in column A (Policy#s) when I remove duplicates, there are 1310 unique characters out of 5064 rows. In the extract tab, there are only 220 policy numbers show up. Why is that?

  15. #15
    Registered User
    Join Date
    08-13-2015
    Location
    Houston, Texas
    MS-Off Ver
    2010
    Posts
    61

    Re: Formula to grab the next highest number

    Your formula does seem to work for the most part, but I did notice some errors. For example: Policy number 3083378. Your formula didn't grab the next highest lvl after 1, it picked up the following number. Capture.JPG

    Also, when I would filter column J to show everything but empty cells and n/a cells, there were more rows than there unique policy numbers, so there are some duplicates still.

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Formula to grab the next highest number

    I believe this will work. With two helper columns ... in column K this array-entered formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    (Array-entering has already been covered.) Then in column L this non-array formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    And then in column M:U this non-array formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Edit I failed to mention that Helper column L returns the next highest Agent Level number. Sorry.
    Attached Files Attached Files
    Last edited by FlameRetired; 11-03-2015 at 01:14 AM.
    Dave

+ 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: 4
    Last Post: 01-21-2015, 02:07 PM
  2. VBA code to find highest and 2nd highest number based in criteria
    By Michael007 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2011, 08:38 AM
  3. Formula to grab size from part number.
    By fulford in forum Excel General
    Replies: 13
    Last Post: 08-25-2011, 04:47 PM
  4. Formula for value in a column that appears in the highest row number
    By Matt Chis in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-20-2011, 11:33 PM
  5. Grab highest abs. value from a changing field?
    By toorik in forum Excel General
    Replies: 5
    Last Post: 12-16-2010, 03:27 AM
  6. highest number formula
    By maestro_uk in forum Excel General
    Replies: 4
    Last Post: 08-28-2007, 10:36 AM
  7. Replies: 3
    Last Post: 08-10-2006, 11:40 PM

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