+ Reply to Thread
Results 1 to 6 of 6

Mac: Issue with using Lookup to find last non-empty value in range

  1. #1
    Registered User
    Join Date
    04-17-2019
    Location
    London. England
    MS-Off Ver
    Excel 16.23
    Posts
    3

    Mac: Issue with using Lookup to find last non-empty value in range

    Hi all,

    I have a weird issue when using the following formula to find the last non-empty value in a range:

    =LOOKUP(2,(1/A:A<>""),A:A)

    I understand how this formula works by creating an array or either 1s or DIV/0 errors and then failing to match with 2, taking the last 1 value. This formula has been working nicely on my spreadsheets for 2 years now. But all of a sudden it has started to do something weird. If I click on the cell the formula is in and press enter it stops taking the last non empty cell and takes the second to last, and I can't make it return to taking the last non empty cell again.

    Also, if the range only has one non-empty value, then it suddenly started returning #N/A error, until I click on the cell and press enter to re-run the formula and then it works.

    It never used to do this. And also it only affects certain instances of this formula but not others, and the affected ones changes randomly. I think it may be related to the values in the range themselves not been hardcoded but the result of an INDEX(A:A,MATCH(B,A:A,0)) formula or simply a cell reference to another tab. If I hard code the data in the ranges the LOOKUP formula works fine.

    Is this an error in Excel? I'm using it on a Mac. It seems really strange.

    Grateful for any insight.

    Thanks,

    Alex

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

    Re: Issue with using Lookup to find last non-empty value in range

    Welcome to the forum!

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-17-2019
    Location
    London. England
    MS-Off Ver
    Excel 16.23
    Posts
    3

    Re: Issue with using Lookup to find last non-empty value in range

    Thanks,

    I've uploaded a version with dummy data. If you go to cell M51 for instance, it should pull the last value from the range L13:L21. But if you click on M51 and then press enter it stops doing this and pulls the second to last value.

    I think it may be something to do with the fact that data in the range L13:L21 is pulled from range J326:J1828 which as data that is the result of multiple calculations in other ranges.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,379

    Re: Issue with using Lookup to find last non-empty value in range

    The sample workbook is full of formula errors. The reason M51 is returning the penultimate value is because the next cell down is returning an error, not a value.

    Focus your efforts on fixing those errors first.

  5. #5
    Registered User
    Join Date
    04-17-2019
    Location
    London. England
    MS-Off Ver
    Excel 16.23
    Posts
    3

    Re: Issue with using Lookup to find last non-empty value in range

    Thanks for your reply, but I don't have any errors at all in any cell when I open the file on my mac (I wouldn't have uploaded a file with errors - but interestingly when I open the file on a windows machine I do get #N/A errors).

    Screenshot 2019-04-17 at 14.21.25.png

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,379

    Re: Issue with using Lookup to find last non-empty value in range

    Sorry - I can't help you, then - I am on a PC. I'll move this to the Mac section, where it should have been posted.

+ 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. [SOLVED] copy range X number of rows until empty issue
    By iggypop in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-07-2018, 02:18 PM
  2. [SOLVED] VBA Fuzzy Lookup (Find) - Case Sensitive Issue
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-21-2017, 09:59 AM
  3. [SOLVED] Using v lookup but getting the same value due to same range issue
    By ROHAN999 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-28-2016, 12:26 PM
  4. [SOLVED] Lookup the last 3 numbers in the bottom of range without empty cells
    By XLalbania in forum Excel General
    Replies: 8
    Last Post: 08-24-2016, 07:49 AM
  5. [SOLVED] VLOOKUP, gives #N/A error (if Range lookup=0) or wrong data (if Range lookup=empty)
    By Ebalinska in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 01-14-2016, 05:55 AM
  6. First empty row in given range (i.e. C3:G16) - Run Time Error Issue!
    By ncortez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2012, 09:33 AM
  7. shift range of cells to left if find the range of empty do while
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 09:25 AM

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