+ Reply to Thread
Results 1 to 5 of 5

[SOLVED] Find most recent valid cell and return its value

  1. #1
    Registered User
    Join Date
    05-24-2021
    Location
    Japan
    MS-Off Ver
    Microsoft Office Standard 2019
    Posts
    3

    Question [SOLVED] Find most recent valid cell and return its value

    Hello, I'm have what might be a rather basic question for some more experienced members. I don't have much experience yet with index or lookup functions, and I'm looking for some advice.

    I am writing Conditional Formatting rules to draw borders around groups of cells in a table, to visually separate them from one another. I'm having trouble with the top border. Some cells are empty or contain empty strings, so I want to only check those containing a number.

    Here's what I want to achieve:
    From the top of this column to the cell above the current cell, find all cells with a number value.

    Of those, find the one with the highest row number.

    If it holds a value which does not equal the current cell's, apply the condition.
    I think it should look roughly something like this, but I don't have the right syntax because I haven't fully understood how each part works:
    Please Login or Register  to view this content.
    Could someone advise me on how to correctly combine these or similar functions to achieve the required result?
    Attached Files Attached Files
    Last edited by meggatronn; 06-18-2021 at 02:52 AM.

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,461

    Re: Find most recent valid cell and return its value

    Attach a samlple worksheet. See instruction at top of page in yellow banner.
    Quang PT

  3. #3
    Registered User
    Join Date
    05-24-2021
    Location
    Japan
    MS-Off Ver
    Microsoft Office Standard 2019
    Posts
    3

    Re: Find most recent valid cell and return its value

    Thank you for replying. I have attached an abbreviated example to the original post.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,461

    Re: Find most recent valid cell and return its value

    Instead of trying to edit row with top border, try to use another CF for blank row with bottom border
    Stay in cell B2:
    =AND($B2="",$B1 <> $B3,$B2 <> $B3,$B3=1)

    In attachment, I test for Unit 1.
    Add more with unit 2,3,4,5...
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-24-2021
    Location
    Japan
    MS-Off Ver
    Microsoft Office Standard 2019
    Posts
    3

    Thumbs up [SOLVED] Find most recent valid cell and return its value

    Thanks for your reply. It's a good idea, I hadn't thought of testing for blank rows rather than numbered rows! I'll try it out. I'm concerned about cases where there may be more than one blank row together in the middle of a unit, but if I run into problems I'll come back and update.

    UPDATE:
    Your idea worked! The top borders work well. However, I'd like to be able to address cases where there is an interruption of more than one row in a unit, so I'd still like to know the answer to my original question.

    How can I find the previous cell in a column with a number value, and check it against the next cell in the column with a number value? Do you have any ideas?

    Thanks again for your help!

    UPDATE:
    I cracked it!

    Here is the solution I found to the above problem in bold:
    Please Login or Register  to view this content.
    • IF(ISNUMBER(B:B),ROW(B:B)) returns an array of row numbers of those cells in column B that contain numbers.
    • Wrapping that in a MIN or a MAX returns the lowest or highest row number in that array.
    • Wrapping that in a MIN(1, ...) omits zeroes to avoid REF! errors.
    • Wrapping that in INDIRECT("$D"&...) gives the value in the cell in column D in that row.

    In order for this formula to work in a cell, because of the arrays, it needs to be wrapped in curly brackets {=FORMULA(...)}. As a Conditional Formatting rule, this isn't necessary.

    In practice, I don't need to compare the two phrases directly. I just compare $D2 to each half for each CF rule, the top and bottom borders.
    Please Login or Register  to view this content.
    You can see my solution in the example attached.

    If you have a better, more elegant solution, please share it!
    Attached Files Attached Files
    Last edited by meggatronn; 06-18-2021 at 03:08 AM. Reason: update

+ 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. Find duplicates and return most recent
    By FranktheBank in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-12-2014, 02:39 PM
  2. [SOLVED] formula to return next valid cell
    By b2lynch in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-27-2014, 11:38 AM
  3. Replies: 1
    Last Post: 10-01-2013, 01:45 PM
  4. [SOLVED] Formula to Find the Most Recent Date, and Then Return the Corresponding Cell
    By bssol in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-26-2013, 04:12 AM
  5. Return the most recent date from a given cell
    By jrainbow in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-15-2012, 06:03 PM
  6. Find a value in a database for the most recent date, return all values relating to it.
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-22-2012, 01:39 PM
  7. Replies: 4
    Last Post: 03-19-2012, 03:05 PM
  8. Replies: 1
    Last Post: 03-19-2012, 09:43 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