Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Jumping to the Real Last Cell.

Jumping to the Real Last Cell

Written by Allen Wyatt (last updated May 23, 2026)

6

Diane wrote about a problem she was having with a file imported into Excel. The file, created by a non-Excel program, contains 50,000 records, but only the first 87 records contain any data. When the file is imported, pressing Ctrl+End moves to cell J50000 instead of cell J87. Diane was wondering how to make Excel jump to the end of the real data—J87.

The first thing to try is to simply save your workbook, get out of Excel, and then reopen the workbook. Doing so "resets" the end-of-data pointer in the workbook, and you should be fine.

If that doesn't solve the problem, then it is very likely that the data you imported into Excel included non-printing characters, such as spaces. If these are loaded into cells, Excel sees them as data, even though you don't. To fix the workbook by deleting the data, select row 88 (the one right after your data) and then hold down the Shift and Ctrl keys as you press the Down Arrow. All the rows from 88 through the last row in the worksheet should be selected. Press the Delete key, save the workbook, and reopen it. Ctrl+End should work fine.

If you have quite a few of these files you need to "clean up," or if you need to do it on a regular basis, then you need a macro to help you. Consider the following macro:

Sub ClearEmpties()
    Dim c As Range
    Dim J As Long

    J = 0
    Selection.SpecialCells(xlCellTypeConstants, 23).Select
    For Each c In Selection.Cells
        J = J + 1
        StatusBar = J & " of " & Selection.Cells.Count
        c.Value = Trim(c.Value)
        If Len(c.Value) = 0 Then
            c.ClearFormats
        End If
    Next
    StatusBar = ""
End Sub

This macro selects all the cells in the worksheet that contain constants (in other words, they don't contain formulas). It then steps through each of those cells and uses the Trim function to remove any leading or trailing spaces from the contents. If the cell is then empty, any formatting is cleared from the cell.

When the macro is done, you can save and close the workbook, reopen it, and you should be able to use Ctrl+End to go to the real end of your data. If this still doesn't work, it means that the cells being imported into the workbook have some other invisible, non-printing character in them. For instance, there could be some bizarre control characters in the cells. In this case, you need to talk with whoever is creating your import file. The best solution, at this point, would be for the person to modify their program so it doesn't include the "trash" that Excel is mistaking for valid cell content.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9811) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Jumping to the Real Last Cell.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Unwanted Vertical Lines in a Table

When you print a table that includes borders, those borders should be crisp and clear on the printout. If you get some ...

Discover More

Positioning a Graphic in a Macro

Macros are a great way to process information in a worksheet. Part of that processing may involve moving graphics around ...

Discover More

Looking Backward through a Data Table

Sometimes you need to look backward, through the information above your formula, to find the data you need. This can be ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!

More ExcelTips (ribbon)

Tying a Named Range to a Value Instead of a Cell

Named ranges are great, but they don't move when you sort data. If you want them to move, it is helpful to remember that ...

Discover More

Changing Your Name

One of the many pieces of information that Excel keeps track of is your name. If you want to change your name for Excel's ...

Discover More

Freezing Both Rows and Columns

When you are working in a worksheet, you may want to freeze the rows at the top or left of the worksheet. Excel provides ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four more than 7?

2026-05-26 17:10:35

J. Woolley

Re. my most recent comment below, these changes will make the ClearEmpties3 macro run faster.nReplace this statementn    If Len(Trim(ConvUniSpaces(WorksheetFunction.Clean(c.Value)))) = 0 Thennwith this statementn    If Len(RemoveUniSpaces(WorksheetFunction.Clean(c.Value))) = 0 Thennand replace the ConvUniSpaces function with the following function:nnFunction RemoveUniSpaces(Text As String) As Stringn    Const UniSpaces = "\s|[\u00A0\u2000-\u200A\u202F\u205F\u3000]"n    With CreateObject("VBScript.RegExp")n        .Pattern = UniSpaces: .Global = Truen        RemoveUniSpaces = .Replace(Text, vbNullString)n    End WithnEnd FunctionnnIt might be necessary to use VB Editor's Tools menu to Reference the Microsoft VBScript Regular Expressions 5.5 library. The latest version of the VBA library includes RegExp; in this case, you can replace this late binding statementn    With CreateObject("VBScript.RegExp")nwith this statementn    With New RegExpnfor early binding, but the macro will probably fail when using Excel 2024 or an earlier version.


2026-05-25 15:32:26

J. Woolley

@Alex BlakenburgnThank you for your comment. I was not aware the SpecialCells problem was fixed in Excel 2010. Here's another version of the macro that addresses merged cells and Unicode space characters plus status bar display.nnSub ClearEmpties3()n        Dim c As Range, J As Long, K As Long, sSB As String, bDSB As Booleann        ActiveSheet.UsedRange.Selectn        On Error Resume Nextn                Selection.SpecialCells(xlCellTypeConstants, xlTextValues).Selectn                If Err Then Exit Subn        On Error GoTo 0n        sSB = Application.StatusBarn        bDSB = Application.DisplayStatusBarn        Application.DisplayStatusBar = Truen        K = Selection.Cells.Countn        For Each c In Selectionn                J = J + 1: Application.StatusBar = J & " of " & Kn                If Len(Trim(ConvUniSpaces(WorksheetFunction.Clean(c.Value)))) = 0 Thenn                        c.MergeArea.Clearn                End Ifn        Next cn        Application.StatusBar = IIf(sSB = "FALSE", False, sSB)n        Application.DisplayStatusBar = bDSBn        ActiveSheet.UsedRange.SelectnEnd SubnnFunction ConvUniSpaces(Text As String) As Stringn        Static UniSpaces As Variant, n As Integern        If IsEmpty(UniSpaces) Thenn                UniSpaces = Array(ChrW(&HA0), "NO-BREAK SPACE", _n                        ChrW(&H2000), "EN QUAD", _n                        ChrW(&H2001), "EM QUAD", _n                        ChrW(&H2002), "EN SPACE", _n                        ChrW(&H2003), "EM SPACE", _n                        ChrW(&H2004), "THREE-PER-EM SPACE", _n                        ChrW(&H2005), "FOUR-PER-EM SPACE", _n                        ChrW(&H2006), "SIX-PER-EM SPACE", _n                        ChrW(&H2007), "FIGURE SPACE", _n                        ChrW(&H2008), "PUNCTUATION SPACE", _n                        ChrW(&H2009), "THIN SPACE", _n                        ChrW(&H200A), "HAIR SPACE", _n                        ChrW(&H202F), "NARROW NO-BREAK SPACE", _n                        ChrW(&H205F), "MEDIUM MATHEMATICAL SPACE", _n                        ChrW(&H3000), "IDEOGRAPHIC SPACE")n        End Ifn        ConvUniSpaces = Textn        If Len(ConvUniSpaces) > 0 Then 'replace UniSpaces with ASCII spacen                Const A_SPACE = " "n                For n = LBound(UniSpaces) To UBound(UniSpaces) Step 2n                        ConvUniSpaces = Replace(ConvUniSpaces, UniSpaces(n), A_SPACE)n                Next nn        End IfnEnd Function


2026-05-25 02:57:32

Alex Blakenburg

We don't really have enough information to provide a robust code solution. With the data being "imported" formatting is unlikely to be an issue. Neither macro handles non-breaking spaces (ASCII 160) but that also seems unlikely for an imported file. Both macros will fail if there are merged cells, again unlikely for an imported file.nnA non-US regional setting could impact dates in the original macro provided but unlikely to impact numbers (they will stay as numbers despite the use of Trim).nLooping through almost 50k rows 1 cell at a time is not going to be quick. if there a lot of empty cells sprinkled through the 50k rows, you will wind up with a large number of non-contiguous cells in the selection.n@J. Woolley - Re: 8,192 non-contiguous ranges (Areas) limit.nRefer to:nhttps://jkp-ads.com/rdb/win/s4/win003.htmn"Note: This problem is fixed in Excel 2010nNon-contiguous cells that can be selected in Excel 2010 : 2,147,483,648 cells"nnMind you I tested it on around 30k areas and the macro gets really ... slow as the number of non-contiguous ranges increases.


2026-05-24 10:30:31

J. Woolley

The Tip's ClearEmpties macro starts with the following statement:n        Selection.SpecialCells(xlCellTypeConstants, 23).SelectnThe result will be unreliable unless the user selects all cells (Ctrl+A) before running the macro. And the macro has some undesirable side effects for cells that contain a text constant:n1. If the text is numeric it is converted to a number (non-text).n2. If the text is a date it is probably converted to a number (non-text).n3. If the text has leading or trailing space characters they are removed.nThese side effects become permanent if the workbook is saved. Finally, cells that contain only non-printing characters and/or line breaks (with or without space characters) should be cleared but are not.nHere's an alternate version that resolves these issues:nnSub ClearEmpties2()n        Dim c As Rangen        ActiveSheet.UsedRange.Selectn        For Each c In Selection.SpecialCells(xlCellTypeConstants, xlTextValues)n                If Len(Trim(WorksheetFunction.Clean(c.Value))) = 0 Then c.Clearn        Next cn        ActiveSheet.UsedRange.SelectnEnd SubnnClearEmpties2 ignores the StatusBar because it runs too quickly for the user to notice. ActiveSheet.UsedRange updates the last used cell, so it is not necessary to save the workbook in order to reset Ctrl+End.nWarning: The SpecialCells method fails silently if it identifies more than 8,192 non-contiguous ranges (Areas), but this is unlikely.


2026-05-23 08:14:14

Graham Rice

A couple of points about the "simple" answer :-nnThere is no need to get out of Excel and reopen the workbook. nAfter saving, you can keep the workbook open and immediately test the location of the last cell with Ctrl-End.nnThis resetting of the last cell automatically works for EVERY worksheet in the workbook, not just the active worksheet.nThere is no need to repeat the process for the other worksheets.


2026-05-23 06:00:27

Alex Blakenburg

FYI - It is the Save function of the workbook that recalculates the UsedRange on which the Ctrl+End relies. So after the macro Ctrl+End should change after you hit Save. There should be no need to Close and ReOpen the workbook.nnPS: Also both references to the StatusBar should say Application.StatusBar (with Option Explicit set - the current code errors out)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.