
Tips.Net > ExcelTips Home > Data Entry > Navigation > Jumping to the Real Last Cell
Summary: Jumping to the last cell in a worksheet should be easy, but you may not always get the results that you expect. This tip looks at why this could be the case and how you can get around the problem. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
Diane wrote about a problem she was having with a file imported into Excel. The file, created by a non-Excel program, contains 65,536 records, but only the first 87 records contain any data. When the file is imported, pressing Ctrl+End moves to cell J65536 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 65536 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.
Tip #3297 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Make Home Buying Less Stressful! Why face the annual problems associated with Christmas debt? Learn how to avoid that debt and conquer your financial challenges.
Check out Buying a Home Checklist today!
Want to make Excel do even more? The way is easy when you know how to use macros. This great e-book makes it easy. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site