+ Reply to Thread
Results 1 to 5 of 5

Ghost last cell used

Hybrid View

  1. #1
    Registered User
    Join Date
    02-13-2012
    Location
    East-London, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    13

    Ghost last cell used

    Hi All,

    I use Excel 2010. I have an workbook with several worksheets used as database. All rows and columns that are not used are hidden. When a new record is added, the first hidden row following the last record (used row) is unhidden.

    After some use the last cell used is moved to a cell with no data sometimes more tha double the number of rows further than the actual last row. If I run MsgBox ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Address the response is way beyond the actual last cell used.

    I have tried everything, (a) delete all rows up to and beyond the ghost last cell, and (b) delet the "contents" of all cells up to and beyond the ghost last cell, to no avail.

    If I copy and paste the actual data to a new worksheet, the actual last cell used is given.

    I assume a marker is put in the worksheet one or other way where the last used cell is.

    My question is: How do I correct this marker without having to go through the schlep of copy and past to a new worksheet which creates a lot of additional work to format, reset cell addresses, etc?
    Last edited by Zagrijs; 02-27-2012 at 09:27 AM.

  2. #2
    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
    48,064

    Re: Ghost last cell used

    The LastCell can be unreliable and is affected by new and deleted rows. Deleting blank rows beyond the last used row and saving the workbook usually resolves this.

    I prefer to use a column where there is known to be data in all rows. For example:

    Dim lLR As Long
    lLR = Range("A" & Rows.Count).End(xlUp).Row
    Msgbox lLR


    This doesn't rely on internal flags or counters and will return the last row used. Add 1 for the NEXT free row.

    Regards, TMS
    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


  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Ghost last cell used

    Hi Zagrijs,

    This is interesting....!!
    Not sure but it may be happening because of row insertion process which may move down the used rows / cells..

    If possible, post the file for forum to have a quick look. Thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Ghost last cell used

    Excel often mistakes the last cell, after changes to a sheet

    http://support.microsoft.com/kb/244435
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    02-13-2012
    Location
    East-London, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Ghost last cell used

    Thanks to both for the replies.

    The workbook is to big and coding complex to load.

    I will follow the proposal to work on a column where all cells are known to have data

    Regards

    Zagrijs

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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