+ Reply to Thread
Results 1 to 13 of 13

The row number of the last cell containing a particular item

  1. #1
    Registered User
    Join Date
    02-02-2006
    Location
    Sydney . Australia
    MS-Off Ver
    2007 and 2013
    Posts
    98

    The row number of the last cell containing a particular item

    Different items are repeatedly entered in a column. A formula is required to workout the row number of the cell cotaining the last entry of a particular item.
    Please see attached sample worksheet.
    Thanks in advance.
    Attached Files Attached Files
    Last edited by Michael6; 06-17-2011 at 04:53 AM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: The row number of the last cell containing a particular item

    Michael6,

    The following formula is an array formula, and so needs to be entered with CTRL+SHIFT+ENTER:
    =MAX(IF(A:A="B",ROW(A:A),0))

    Hope that helps,
    ~tigeravatar

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: The row number of the last cell containing a particular item

    Hi Michael, try this the uploaded workbook
    Attached Files Attached Files
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: The row number of the last cell containing a particular item

    You beat me to it Tiger!! I did mine with code though because I am not fluent with worksheet functions.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: The row number of the last cell containing a particular item

    @Mordred, hehe, sorry about that I was just looking at your code. You're definitely improving

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: The row number of the last cell containing a particular item

    Thanks for that tiger although I did trap an error if there are no "B"s is the cells and had to change my code to this:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-02-2006
    Location
    Sydney . Australia
    MS-Off Ver
    2007 and 2013
    Posts
    98

    Re: The row number of the last cell containing a particular item

    Thank you tigeravatar, but this formula gives me the error #NUM!
    And apart from that,for some reason, I would rather use a nonarray formula if possible.
    Your help is appreciated

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: The row number of the last cell containing a particular item

    Michael6,

    The #NUM error is because I was using excel 2007 and referred to an entire column. I have changed the formula. Its still an array formula so need to use CTRL+SHIFT+ENTER:
    =MAX(IF(TRIM($A$1:$A$10000)="B",ROW($A$1:$A$10000),0))


    Attached is a modified version of your sample workbook so you can see how it works

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

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

    Re: The row number of the last cell containing a particular item

    Another way is an array formula like this

    =MATCH(2,1/(A1:A20="B"))

    or to make it non-array, with added INDEX

    =MATCH(2,INDEX(1/(A1:A20="B"),0))
    Audere est facere

  10. #10
    Registered User
    Join Date
    02-02-2006
    Location
    Sydney . Australia
    MS-Off Ver
    2007 and 2013
    Posts
    98

    Re: The row number of the last cell containing a particular item

    Hi Mordred,
    Thanks for your trying to help, but I am absolutely unfamiliar with this sort of formula, and I don't think I will be able to fit it in a bigger formula in my original Spreadsheet.
    Last edited by Michael6; 06-15-2011 at 06:36 PM.

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

    Re: The row number of the last cell containing a particular item

    See my post for a non-array version....

    ....but I note you talk about a "bigger formula". What's the ultimate aim here - if you are finding the row number to use in a larger formula then there are probably better ways to achieve the final result

  12. #12
    Registered User
    Join Date
    02-02-2006
    Location
    Sydney . Australia
    MS-Off Ver
    2007 and 2013
    Posts
    98

    Re: The row number of the last cell containing a particular item

    Thank you daddylonglegs.Your formula is what I actually asked for.But it will be great of you if you can modify it by changing the range [$A$1:$A$20] to the range[ $A$1: WEEKNUM(TODAY()).] I mean that the end of the range has to be the cell of the row number that is the number of today's week.The week starts MONDAY.

  13. #13
    Registered User
    Join Date
    02-02-2006
    Location
    Sydney . Australia
    MS-Off Ver
    2007 and 2013
    Posts
    98

    Re: The row number of the last cell containing a particular item

    Thank you tigeravatar. This modified formula works OK. But the nonarray formula given by daddylonglegs is what I am actually after.
    Regards
    Michael

+ 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