VBA & Macro Problems

Override the End Key in Excel to Go to the Last Populated Cell

Anum MushtaqAnum Mushtaq Nov 22, 2026 870 views

Question details

The user wants the End key to move directly to the last populated cell instead of activating Excel's End mode.

Override the End Key in Excel to Go to the Last Populated Cell
Product
Microsoft Excel
Device & OS
not provided
Scenario
Navigating a worksheet with the End key.
Observed behavior
Pressing End activates End mode, after which an arrow key is needed to move through the data region.
Before you start

This VBA method requires a desktop version of Excel that supports macros. If you do not already have PERSONAL.XLSB, create it by recording a short macro with Store macro in set to Personal Macro Workbook, then stop recording.

Solution 1Recommended

Remap End with a macro in PERSONAL.XLSB

Use VBA to make End select the last cell containing a value or formula in the current row.

Excel has no built-in setting to permanently change End mode. This macro changes the key's behavior in worksheets while the assignment is active; it does not change how End works when editing cell text.

1
Open the VBA editor

In desktop Excel, open the VBA editor with Alt+F11 or Developer > Visual Basic. In the Project Explorer, find VBAProject (PERSONAL.XLSB).

2
Add the navigation macro

Select VBAProject (PERSONAL.XLSB), choose Insert > Module, and paste: Sub MyEndKey() Dim ws As Worksheet Dim target As Range Set ws = ActiveSheet Set target = ws.Rows(ActiveCell.Row).Find(What:="*", After:=ws.Cells(ActiveCell.Row, 1), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False, SearchFormat:=False) If Not target Is Nothing Then target.Select End Sub

3
Assign the End key at startup

Under VBAProject (PERSONAL.XLSB), double-click ThisWorkbook and add: Private Sub Workbook_Open() Application.OnKey "{END}", "'PERSONAL.XLSB'!MyEndKey" End Sub

4
Save and restart Excel

Save PERSONAL.XLSB in the VBA editor, close Excel, and reopen it. Enable macros if prompted, then select a worksheet cell and press End to test the shortcut.

Remap End with a macro in PERSONAL.XLSB
Restore the original End behavior: In the VBA editor, open View > Immediate Window and run Application.OnKey "{END}". To keep the default behavior after restarting Excel, also remove the assignment from the Workbook_Open procedure and save PERSONAL.XLSB.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative for working with spreadsheets in a familiar interface. Open compatible Excel files and continue working without a complex migration; it does not change Microsoft Excel's End key behavior.

Navigate and edit worksheet data in WPS SpreadsheetsOpen and save compatible Microsoft Excel XLS and XLSX filesUse a familiar spreadsheet interfaceWork with a free, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Can I change Excel's End key behavior without VBA?

Excel does not offer a built-in setting to permanently remap End. Without a macro, use Ctrl+Arrow to move to the edge of a data region.

What happens if the current row is empty?

The macro's Find operation returns no cell, so pressing End leaves the active cell unchanged.

Does the macro find cells containing formulas?

Yes. The macro uses LookIn:=xlFormulas, so it can find a cell containing a formula even if the formula displays an empty result.

Why does the End key still activate End mode after restarting?

Check that the macro is in a regular module in PERSONAL.XLSB, the Application.OnKey assignment is in its ThisWorkbook module, and macros are enabled. Save PERSONAL.XLSB and restart Excel again.

Does remapping End change its behavior while I edit a cell?

No. The VBA assignment is intended for worksheet navigation; it does not change the End key's text-editing behavior inside a cell.