+ Reply to Thread
Results 1 to 13 of 13

Find last numerical value in row range and return the column header

  1. #1
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Find last numerical value in row range and return the column header

    Hi All,

    I'm analysing a large sheet of data and need some assistance:

    What I need is to have a formula to find the last numerical value in a row and then return the column header. Basically, this is to do with projecting destruction dates for files in storage over the next 10 years and I want an extra column to display text along the lines of 'Box destruction due in x year' for that row.

    Note: Each row is a subtotal which calculates the number of files within a box. To add to the confusion, there are two types of box; 'Mixed Files' which contain files that cannot be destroyed along with files that can and 'Complete Box' which only contains files that can be destroyed. I will modify any formula to include this argument.

    I have something crude which kind of works but is basically a long collection of nested IF statements, one for each year, and I want something a bit more streamlined. Call me old skool but I believe any code can be condensed and work the same, if not better.....

    I have played about with the 'INDEX' and 'MATCH' functions but not quite got it to work for me.

    Thanks for any help!
    Tony
    Last edited by Fidd$; 03-04-2011 at 10:15 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Find last numerical value in row range and return the column header

    Maybe this, if you were looking at row 2?

    =INDEX(A1:E1,1,MATCH(LOOKUP(9.99999999999999E+307,A2:E2),A2:E2,0))

  3. #3
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    Thanks for the formula StephenR, it works in that it returns the last numerical value but I need it to return the respective column header as well.
    How to change the formula to incorporate this?

    Also, I will be amending the formula to include the arguments for the box descriptions as explained in my post so will possibly be adding in a few 'IF' statements in there. Would this be advisable or is there another way?

    Cheers!

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Find last numerical value in row range and return the column header

    Thanks for the formula StephenR, it works in that it returns the last numerical value but I need it to return the respective column header as well.
    How to change the formula to incorporate this?
    Hi

    Stephens formula returns the header ( situated in row1) of the last numerical value correctly
    Is that not what you need?

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Find last numerical value in row range and return the column header

    Quote Originally Posted by StephenR View Post
    =INDEX(A1:E1,1,MATCH(LOOKUP(9.99999999999999E+307,A2:E2),A2:E2,0))
    I don't think this will always work, for example if there are duplicates. If the last value is in E2 and is 10.....but 10 also appears in A2 then the formula returns the value from A1

    Try this version

    =LOOKUP(9.9E+307,A2:E2,A$1:E$1)
    Audere est facere

  6. #6
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    Yep, sorry Stephen, I have looked at formula closer and found where it refers to header row (row 1) in BOLD:

    =INDEX(R15:AC15,1,MATCH(LOOKUP(9.99999999999999E+307,R15:AC15),R15:AC15,0))

    I have it changed now so returns header. Thanks for pointing out Arthur. Any pointers on my second post regarding using this with 'IF' statements?

    Yes, Daddylonglegs, you are correct. Some of the numbers do reiterate along the row until it hits the 'Year of Destruction' and then the 'IF' statements return 'N/A'. This woudln't really be an issue though as the number should always increase until it gets to the stage where the number equals the total number of files in that box (present in another column), therefore the last number will always be larger and hence different from the ones before it.
    Still, this will also come in handy one day I'm sure
    Last edited by Fidd$; 03-01-2011 at 11:45 AM. Reason: additonal text

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Find last numerical value in row range and return the column header

    I should never dabble in formulae - please note daddylonglegs's caveat in case it applies. I think you may have to elaborate as to what these IF statements might cover.

  8. #8
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    Stephen, the IF statements are to determine what kind of Box it is - one with all files to be destroyed or one that has both destroyable files and files which cannot be destroyed. I have this part covered, as in a how many non-destroyable to destroyable files ratio in a box.
    What I would like to add into this INDEX formula is to have an IF statement determine which one of those two boxes it is and change the text output accordingly.

    Hope this makes sense!

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Find last numerical value in row range and return the column header

    Quote Originally Posted by Fidd$ View Post
    Any pointers on my second post regarding using this with 'IF' statements?
    Do you mean that you might not want the last number because that might be associated with "Mixed files". How can you tell, is there a row that says "Mixed" or "Complete"?

  10. #10
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    Daddylonglegs, please find attached a sample workbook, this may explain what I'm trying to achieve with the IF statements.
    The full worksheet contains over 60,000 rows so it is a megabeast in terms of an easily workable Excel sheet!
    Attached Files Attached Files

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Find last numerical value in row range and return the column header

    OK, so do you want to simplify the formulas in S6:AC6 or are they only a means to get the results in AD6 and AE6, you could probably get rid of the formulas in S6:AC6 altogether and just calculate those 2 directly.....

  12. #12
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    I added in each year (columns S:AC) as that was the only way I could think of to calculate in which year each box would be due for destruction (using COUNTIF($R2:$R5,"<=31/12/2014" and checking if this equaled AE6, the number of files in box which is calculated from column L), then in turn use these values to give me the year, hence the need to find last numeral in row.

    What I created doesn't look pretty at all(!) so if this can be done without the need for the columns S:AC then it will be much better.

  13. #13
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel XP, 2003, 2010
    Posts
    125

    Re: Find last numerical value in row range and return the column header

    Marking as solved as I will need each column for each Year's projection so cannot get rid of them and ultimately simplifying how the results are calculated.

    Thanks for the help on this from everyone, much appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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