+ Reply to Thread
Results 1 to 6 of 6

Finding Last occupied row

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Finding Last occupied row

    I have puzzling situation that I would like some help with
    I have a large worksheet which is being added to. The addition is a column of names and a years dates. In the attached workbook the list of names is shorter and only a few dates have been added.
    I know that the last record appears in a column that I can identify. I want to identify the range that has been added and apply various borderlines to it.
    This is the code I use.
    Please Login or Register  to view this content.
    Startplace is the column number of the column to start the new matrix
    YearLen is either 365 or 366
    lrow is the last row of the matrix area. It is found in the column which precedes StartPlace.
    MakeMatrix is the procedure that provides the border lines.

    My problem is that code above does not work. It will sometimes work as I step through the code, but if I run the code it always says that lrow = 0
    The much reduced sample I produced for the attached workbook always works, though.
    The only difference between the actual and the sample is that ROW 9 to the left of the start of the new area consists of 12 monthly merged groups of cells.
    I am completely flummoxed and badly need some guidance
    John
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Finding Last occupied row

    It has just occurred to me that the procedure must be looking at the wrong column. Is there a way I could find if that is true?

  3. #3
    Registered User
    Join Date
    04-12-2011
    Location
    Bay Lake, FL
    MS-Off Ver
    Excel 2016 / 365
    Posts
    66

    Re: Finding Last occupied row

    Could you just find the lastrow using something like this, and then work from there? This will check Column A, but can be (very) easily modified to look at a different column instead.
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Finding Last occupied row

    Try this

    Please Login or Register  to view this content.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: Finding Last occupied row

    Quote Originally Posted by j_Southern View Post
    if I run the code it always says that lrow = 0
    That shouldn't be possible with that code. The minimum value for lrow (assuming the line that assigns it has actually run) should be 1, even if you were looking at a blank column.
    Rory

  6. #6
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,416

    Re: Finding Last occupied row

    This line of code will find the last row with data no matter what column it is located in...
    Please Login or Register  to view this content.

+ 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. I Need to highlight last occupied cell in each row.
    By rwgauger in forum Excel General
    Replies: 1
    Last Post: 01-26-2019, 08:46 PM
  2. How to get the occupied position in vba ?
    By woshichuanqilz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2017, 09:09 PM
  3. Last occupied cell in row or column
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2014, 01:18 PM
  4. Autofill column until next occupied
    By james.chen in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-24-2013, 06:00 PM
  5. Counting Occupied cells
    By ohaganli in forum Excel General
    Replies: 6
    Last Post: 10-17-2012, 08:45 AM
  6. Replies: 2
    Last Post: 01-30-2011, 02:50 PM
  7. how to add all occupied cells in one row
    By lrneilson in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 07-21-2008, 08:04 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