+ Reply to Thread
Results 1 to 8 of 8

Look up last cell number containing data

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Bristol, UK
    MS-Off Ver
    Excel 16.94
    Posts
    48

    Look up last cell number containing data

    I have used variations on:
    MATCH(LOOKUP(2,1/(NOT(ISBLANK(3:3))),3:3),3:3,0)
    or
    MATCH(LOOKUP(2,1/(G3:AC3<>""),G3:AC3),G3:AC3,0)

    but the problem with both is that if there are identical values in the row, eg. cell 5="x" and cell 7="x", I get "5" returned, not "7".

    Now this row's cells, generally contains text, so most of the time it's OK, but there are exceptions.

    How do I guarantee to get the eg. 8th cell in the row returned as "8", if that is the last cell containing text or a number, even if there is an earlier cell containing an identical entry?

    Is there any advantage using xlookup?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,189

    Re: Look up last cell number containing data

    XLOOKUP isn't in your version (2011), so please update your forum profile.

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,004

    Re: Look up last cell number containing data

    Try:

    =LOOKUP(99^99, G3:AC3, COLUMN(G3:AC3))

    Maybe some adjusting will be needed as -3 or something...
    Last edited by zbor; 03-09-2025 at 03:00 AM.
    Never use Merged Cells in Excel

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Look up last cell number containing data

    Maybe one of these:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    12-23-2012
    Location
    Macksville, Australia
    MS-Off Ver
    Excel 365
    Posts
    9

    Re: Look up last cell number containing data

    Quote Originally Posted by tays01s View Post
    Now this row's cells, generally contains text, so most of the time it's OK, but there are exceptions.
    The suggestions in posts 3 & 4 will tell you what column the last number is in but not the last text or the last of either if the type is unknown.
    Your original formulas were sort of on the right track but you don't want the MATCH function but instead introduce the COLUMN function.
    So you could try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    However, I would generally recommend not to use the whole row reference. I would pick a smaller range but make sure it would be big enough to cover any data that you might have.
    For example it might be
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Another function option would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Hope this helps, good luck.
    Peter

  6. #6
    Registered User
    Join Date
    05-08-2013
    Location
    Bristol, UK
    MS-Off Ver
    Excel 16.94
    Posts
    48

    Re: Look up last cell number containing data

    I will experiment with the suggestions, but here is a sample blank sheet.

    I've updated my profile: I use Excel 16.94.
    Thanks,
    Stephen
    Attached Files Attached Files

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,004

    Re: Look up last cell number containing data

    MATCH with match type 0 will return you first instance.
    Some of above solution will return you latest position like for example =LOOKUP(2,1/(F3:AZ3<>""),COLUMN(F:AZ))

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,995

    Re: Look up last cell number containing data

    Updated sample file with a variety of solutions.
    Attached Files Attached Files

+ 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: 5
    Last Post: 06-11-2023, 09:43 PM
  2. Using a Textbox to find row number to populate data into that row by indicated cell number
    By SteynfaardtD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2019, 02:14 AM
  3. Replies: 2
    Last Post: 04-30-2017, 08:28 PM
  4. [SOLVED] Enter number in blank cell match number on sheet 2 & enter data from adjacent cell
    By Bikeman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-10-2015, 08:36 PM
  5. Replies: 1
    Last Post: 06-03-2013, 06:22 AM
  6. Replies: 4
    Last Post: 05-18-2009, 03:02 AM
  7. Replies: 7
    Last Post: 09-26-2007, 11:52 AM

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