+ Reply to Thread
Results 1 to 18 of 18

Find the last Cell with content in a given range.

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Find the last Cell with content in a given range.

    In my worksheet all the cells in F6:F100 have formulas , either resolving to content or remaining blank.

    I'm trying to find and select the last cell in F6:F100 with content , and make it bold.

    Can someone suggest some VBA to satisfy this?


    Grateful for any advice.

    Last edited by CDandVinyl; 02-19-2024 at 10:33 PM.
    Using Excel , Word and Access 2003 - For the whole of 2024

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Find the last Cell with content in a given range.

    Take your pick and change to fit your needs
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    Thanks jolivanes. This gives a message box with the row number containing the last content. It doesn't go to the specific cell in the range and make it bold. Perhaps it can be modified to do this.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Find the last Cell with content in a given range.

    I thought that someone with over 600 posts would be able to do that himself.
    How else are you ever going to learn. It's commonly known as trial and error.

  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    Jolivanes - but I *am* working on modifying your suggestion. I said this in my response. Post #3.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Find the last Cell with content in a given range.

    Quote Originally Posted by jolivanes View Post
    I thought that someone with over 600 posts would be able to do that himself.
    How else are you ever going to learn. It's commonly known as trial and error.
    This is unnecessarily snarky. I understand why you said this but this is not the tone we would like to see here.

    Quote Originally Posted by CDandVinyl View Post
    Thanks jolivanes. This gives a message box with the row number containing the last content. It doesn't go to the specific cell in the range and make it bold. Perhaps it can be modified to do this.
    The code gives you the building blocks to finish your solution. It shows you how to find the last cell containing content. When you post in the VBA forum and ask a VBA question, it is helpful to give some idea of your level of VBA skills. We need to know if you are trying to get past a sticking point ("How do you find the last cell with content?") or whether you need more ("Please do this whole thing for me"). Also, the phrase "last cell with content" is not precise in Excel. It could mean "the last cell with a formula" or it could mean "the last cell with a formula that returns a non-null result." The code covers either case, so it is back to you to say which one you want.

    Just for the sake of keeping this moving, here is the solution for looking for the last cell with a formula:
    Please Login or Register  to view this content.
    I have not tested this because I have not taken the time to create a test file from scratch. Consider attaching a file with sample data for testing purposes.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find the last Cell with content in a given range.

    Here is also a solution with Conditional formatting:


    Please try this Conditional formatting formula applied to $F$6:$F$100:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you are upgraded to to latest version of Excel 2016 or newer also this CF-rule is possible:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 02-20-2024 at 12:31 AM.

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Find the last Cell with content in a given range.

    Try
    Code:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Find the last Cell with content in a given range.

    CDandVinyl,

    Error trapping is impportant...
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Find the last Cell with content in a given range.

    If I hurt peoples feelings, my apologies. However, nowhere in the response in Post #5 does it mention what had been tried and that is what I was waiting for.
    I don't off hand remember which respected helper has his signature as
    "Give some a fish and he eats for a day, teach him how to fish and he'll eat forever."
    In my opinion, that fits the problem here,
    No hard feelings though.

  11. #11
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    Thanks guys for your help and various solutions. I'm grateful for your support. Problem solved!


  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find the last Cell with content in a given range.

    Thanks for the feedback and rep. . Glad to have helped.

    Which solution did you choose?

  13. #13
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    Hi HansDouwe

    I tried the CF solution manually , and it worked well. It successfully made bold the last entry in the range in F.

    I then tried to make some VBA to have it run in a macro , and presently it makes *all* of the cells in F go bold. The code I'm using is below.

    I need to work on it...

    Please Login or Register  to view this content.
    Last edited by CDandVinyl; 02-20-2024 at 01:08 PM.

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Find the last Cell with content in a given range.

    Sorry, I'm not very familiar with VBA. I expect Jindon, Kvsrinivasamurthy or Jolivanes can say more about this.

  15. #15
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    HansDouwe - Thanks for your help. Much appreciated

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Find the last Cell with content in a given range.

    Hoi Hans.
    As you must have read, I got berated for my Post #4 but I am still waiting for the OP to tell me which of the two suggestion from Post #2 fit his/her needs.
    He/She mentioned that the message Box gave the cell address but no mention if it is the end of values or the last cell with formulae which can go beyond the data range.
    Of course, I assume it is values because it does not make sense to have a potential empty looking cell formatted as bold.
    There are multiple answers available to him/her but here was my idea.
    It does not have the error checking that jindon rightfully suggested should be included.
    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Find the last Cell with content in a given range.

    CF.
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Find the last Cell with content in a given range.

    Thanks Jindon

+ 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] Find random cell content in 1 to 45 cell row and restate in consecutive columns elsewhere
    By GHBrodbeck in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 10-27-2023, 01:35 AM
  2. Replies: 12
    Last Post: 09-11-2023, 03:33 AM
  3. Delete cell content if find a space in relative cell reference
    By kent97 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-05-2015, 12:43 AM
  4. Find and replace, copying content of one cell to a range of cells.
    By Tavendale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2013, 02:19 PM
  5. [SOLVED] Trying to Find selected cell content within another worksheet cell range.
    By Craigside in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-13-2012, 04:36 PM
  6. Find/replace with cell content
    By DeeCeeL in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-06-2010, 10:38 AM
  7. Find Min then Copy Cell Content
    By xury2000 in forum Excel General
    Replies: 2
    Last Post: 07-01-2009, 09:53 PM

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