+ Reply to Thread
Results 1 to 6 of 6

Find the last row in a worksheet

  1. #1
    Valued Forum Contributor
    Join Date
    02-09-2006
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2016
    Posts
    1,075

    Find the last row in a worksheet

    I have tried searching for the answer to this question but the search engine ignores "last" and "row" as being too common or too short!

    I need a formula in my Analysis worksheet that will reference column G in the Sales worksheet and return the value from the last cell in the column that contains data. Sales worksheet contains a list of product sales with a total row at the bottom. The row number for the total will change depending on the number of products sold in a given month. (Sample attached.)

    Thanks in anticipation!
    Attached Files Attached Files
    Trish in Oz
    -------------
    A problem well defined is a puzzle half solved


    If you attach a sample of your workbook it will be easier to find a solution. Remember to remove/replace sensitive data before uploading the file. Look here if you need help with attachments:
    http://www.excelforum.com/faq.php?fa...b3_attachments

  2. #2
    Forum Contributor corinereyes's Avatar
    Join Date
    12-02-2003
    Location
    Philippines
    MS-Off Ver
    MS Excel 2016
    Posts
    520
    Hi tuph,

    I 'am just trying.

    Please Login or Register  to view this content.
    Corine

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    Hi Trish,

    Corinereye's one looks good as it is & I borrowed the idea to give a couple of alternative formula options:

    * =INDEX(Sales!$G:$G,MATCH("TOTAL",Sales!$A:$A,0),1)
    * =VLOOKUP("TOTAL",Sales!$A:$G,7,FALSE)
    (For these it may better to limit the lookup ranges but it's probably not too important in a file this size.)

    Or use a named range by:
    Firstly, selecting the cell on the sales sheet (G106), press [alt + i + n + d], type a name eg "TotalPercentageVar", [add], check that the "refers to" reference is absolute (ie "=Sales!$G$106"), [ok]
    Secondly, selecting the cell on the Analysis sheet, type "=", press [alt + i + n + p], select the name you've just created, [ok] & [enter] to complete the formula.
    Note: the named cell will only work if the named range (&/or the actual cell does not get deleted.

    Some suggestions which are not specific to your question but may make it irrelevant...
    To prevent the cell being deleted & also to make the Sales sheet more user friendly, I suggest:
    1) moving the totals to the top of the sheet (eg row 5) - this way the total won't be affected by the number of data rows b/c it doesn't move.
    & then
    2) scrolling to the top left of the sheet, selecting cell A6, pressing [alt + w + f] to freeze the pane so that the header rows are always visible (no matter how far down you scroll).

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    In a similar vein, but 1 less function call:

    =LOOKUP(9.999E+307,Sales!G:G)

    Richard

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See link for other suggestions

    http://www.xldynamic.com/source/xld.LastValue.html

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  6. #6
    Valued Forum Contributor
    Join Date
    02-09-2006
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2016
    Posts
    1,075
    Wow! Thanks everyone for the time you took to give me such great responses. I like the =VLOOKUP("TOTAL",Sales!$A:$G,7,FALSE) formula (and should have thought of it myself!).

    Thanks again. Problem solved!

+ 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