How to Move to the Next Excel Row When Cells Are Locked
Question details
The user needs the cell selection to automatically jump from the last unlocked cell in a row to the first unlocked cell in the next row of a specific block (rack), rather than skipping to a completely different section.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Scanning barcodes into an inventory spreadsheet that contains multiple racks with both locked and unlocked cells.
- Observed behavior
- Excel's standard behavior skips over locked cells and moves the cursor to the next available unlocked cell globally, which causes it to jump to the next rack instead of the next row within the same rack.
Before applying a macro or formula, verify that only your designated input cells are formatted as 'Unlocked' and that the worksheet is actively protected.
Use a VBA Macro to Control Cell Selection
Since standard Excel settings cannot restrict movement to a specific rack, a VBA macro can detect changes in specific cells and force the cursor to move to the exact starting cell of the next row.
This solution requires you to save your workbook as a Macro-Enabled Workbook (.xlsm). It triggers a specific cursor movement immediately after a barcode is scanned into the final cell of a row.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the Project Explorer panel on the left, double-click the specific worksheet (e.g., Sheet1) where you are scanning barcodes.
Paste a Worksheet_Change event script. You will need to write an IF statement that checks if the modified cell (Target) is the last unlocked cell in your row, and if so, use Range.Select to highlight the first unlocked cell of the next row.
Go to File > Save As, and choose 'Excel Macro-Enabled Workbook (*.xlsm)' from the file type dropdown menu to ensure your code is preserved.

Use a Single Input Column with a TOCOL or WRAPROWS Formula
If you cannot use VBA macros, you can redesign your workflow to scan into a single continuous column, and use dynamic array formulas to display the data in your rack layout.
Automate Your Worksheets Easily with WPS Spreadsheet
WPS Spreadsheet offers robust VBA and macro support, allowing you to easily implement custom cursor movements for barcode scanning. Enjoy seamless compatibility with your existing Excel files.
- 1. Open Your Inventory File: Launch WPS Spreadsheet and open your existing inventory tracker.
- 2. Enable the Developer Tab: Navigate to the top ribbon, click on the 'Developer' tab, and select 'Visual Basic' to open the macro editor.
- 3. Add Your Custom Code: Double-click your active sheet in the left panel, paste your Worksheet_Change cursor movement code, and close the editor.
- 4. Protect the Worksheet: Go to the 'Review' tab, click 'Protect Sheet', and ensure only your specific input cells remain unlocked to guarantee accurate scanning.

Frequently Asked Questions
Why does pressing Enter jump to another section instead of the next row?
When an Excel worksheet is protected, the Tab or Enter keys automatically move the cursor to the next available unlocked cell. If the immediate next cells in a row are locked, Excel will skip over them until it finds an unlocked cell, which is often in a completely different table or rack.
How do I unlock specific cells for barcode scanning?
Select the specific cells you want to scan into, right-click, and choose 'Format Cells'. Navigate to the 'Protection' tab, uncheck the 'Locked' box, and click OK. Finally, go to the 'Review' tab and click 'Protect Sheet' to enforce the rules.
Can I change the default Enter key direction in Excel?
Yes, you can change the global Enter key direction by going to File > Options > Advanced, and changing the 'After pressing Enter, move selection' setting. However, this global setting cannot conditionally skip specific blocks of locked cells within complex forms.
Do barcode scanners automatically press Enter?
Yes, the vast majority of USB and Bluetooth barcode scanners are configured by default to append a 'Carriage Return' (Enter key) suffix immediately after inputting the scanned text. This is what triggers Excel to move to the next cell.




