How to lock rows in Excel (6 easy methods)

To lock the header row in Excel so it stays visible while you scroll, select View > Freeze Panes > Freeze Top Row; to lock several rows, select the row below them and choose Freeze Panes instead.

This guide covers six methods: freezing the top row, freezing multiple rows, split panes, grouped rows, VBA, and sheet protection that stops locked rows from being edited.

How to lock rows in Excel (6 easy methods)
The Freeze Panes menu on the View tab holds Freeze Top Row, and Unfreeze Panes appears once rows are locked. (Image: Microsoft)

Method 1: Using the Freeze Top Row feature

Freeze Top Row keeps row 1 on screen however far down you scroll. It works in Excel for Microsoft 365, Excel 2024, 2021, 2019, 2016 and Excel for the web.

  1. Open the worksheet and scroll to the top so row 1 is the first visible row.
  2. Select the View tab on the ribbon.
  3. Select Freeze Panes > Freeze Top Row.
  4. Scroll down. Row 1 stays fixed, and a slightly darker border appears under it.

Understanding the concept of locking rows in Excel

"Lock rows" means two different things in Excel: keeping rows visible while you scroll, or stopping people from changing them. Each tool below does one job only.

Tool What it locks What it does not do
Freeze Panes / Freeze Top Row Position: rows above the selected cell stay on screen Does not stop anyone typing in those rows
Split Two independently scrolling panes of the same sheet Both panes can still scroll, so nothing is truly fixed
Group (outline) Rows collapse behind a minus button and expand on demand Collapsed rows are hidden, not protected
VBA (FreezePanes, ScrollArea) Freeze position set by code, or a scroll area people cannot leave Anyone who can run macros can undo it
Protect Sheet Content: locked cells cannot be edited Does not keep rows visible while scrolling

Why lock rows in Excel?

Your situation Use this Why
A single header row must stay visible Method 1: Freeze Top Row One click, no cell selection needed
A title block plus a header row, rows 1 to 3 Method 2: Freeze Panes on row 4 Freezes every row above the selection
Compare row 5 with row 180 side by side Method 3: Split Each pane scrolls on its own
Detail rows clutter a summary Method 4: Group rows Collapse and expand sections with one button
The same freeze must apply on every sheet or file Method 5: VBA A macro repeats the setup exactly
Colleagues keep overwriting headers or formulas Method 6: Protect Sheet Locked cells refuse edits until the sheet is unprotected

Method 2: Freezing multiple rows

Freeze Panes locks every row above the selected cell and every column to its left. The frozen block always starts at row 1, so select the first row you want to scroll.

  1. If anything is already frozen, select View > Freeze Panes > Unfreeze Panes first.
  2. Select the row directly below the last row to lock. To lock rows 1 to 3, select row 4 by clicking its row number.
  3. Select View > Freeze Panes > Freeze Panes.
  4. To lock rows and columns together, select the cell below the rows and to the right of the columns instead. Cell B2 locks row 1 and column A; D5 locks rows 1 to 4 and columns A to C.
  5. Scroll down and right to check the thicker border below the last frozen row.
Lock rows in Excel with Freeze Panes on multiple rows and columns
Frozen rows 1 to 3 stay on top while the sheet below scrolls on to row 10 and beyond. (Image: Microsoft)

Method 3: Lock rows using split panes (alternative technique)

Split divides the window into panes that scroll separately. Use it when the rows you want to keep in view are not at the top of the sheet.

  1. Select the row below where you want the split. Selecting row 13 splits the sheet below row 12.
  2. Select View > Window > Split.
  3. Scroll the lower pane to the rows you want to compare; the upper pane keeps its own position.
  4. To split rows and columns at once, select a cell instead of a whole row, such as D5, before selecting Split.
  5. Select View > Window > Split again to remove the split.
Lock rows in Excel using split panes below row 12
Selecting row 13 before View > Split puts the split below row 12, and each pane gets its own scroll bar. (Image: Microsoft)

Freezing from the split view (alternative for custom locking)

A split can be turned into a freeze, which locks the upper pane in place. This gives a custom freeze line chosen by dragging rather than by selecting a cell.

  1. Create the split with View > Window > Split.
  2. Drag the horizontal split bar until the rows you want locked sit above it.
  3. Scroll the upper pane so its first visible row is the first row to lock.
  4. Select View > Freeze Panes > Freeze Panes. The split bar becomes a fixed frozen line.
  5. To undo, select View > Freeze Panes > Unfreeze Panes.

In VBA, ActiveWindow.FreezePanes = True freezes existing split panes in the same way.

Method 4: Use grouping and outline for collapsible rows

Grouping does not freeze rows; it folds detail rows away so the rows that matter stay together on screen.

  1. Select the detail rows to fold, for example rows 3 to 12, by dragging over their row numbers.
  2. On the Data tab, in the Outline group, select Group. If Excel asks, choose Rows and select OK.
  3. Select the minus button beside the row numbers to collapse the group, and the plus button to expand it.
  4. Select the level numbers 1 or 2 at the top of the outline bar to collapse or expand every group at once.
  5. Press Ctrl + 8 if the outline symbols are not showing.
  6. To remove the group, select the same rows and select Data > Ungroup.

For grouped totals built automatically, Data > Subtotal outlines the list and adds summary rows. Subtotal does not work inside an Excel table; convert the table to a range first.

Group rows in Excel with outline level buttons and collapse controls
The level numbers 1, 2 and 3 above the outline bar collapse or expand every group at once. (Image: Microsoft)

Method 5: Using VBA for advanced locking

A macro applies the same freeze line to any sheet and can confine scrolling to a range. Press Alt + F11 to open the Visual Basic editor, select Insert > Module, paste the code and press F5 to run it.

Change SplitRow = 2 to the number of rows to lock and the ScrollArea range to the block people may use. Save the file as a macro-enabled workbook (.xlsm) to keep the code.

Sub LockHeaderRows()
    With ActiveWindow
        .FreezePanes = False
        .SplitColumn = 0
        .SplitRow = 2
        .FreezePanes = True
    End With
    ActiveSheet.ScrollArea = "A1:F200"
End Sub

Sub ClearScrollArea()
    ActiveSheet.ScrollArea = ""
End Sub

SplitRow sets how many rows sit above the split, and FreezePanes = True freezes that split. ScrollArea limits selection to A1:F200; cells outside it cannot be selected. ClearScrollArea sets it to an empty string, which restores the whole sheet.

You should see: Rows 1 and 2 stay fixed while you scroll, and clicking outside A1:F200 does nothing.

Lock rows using Windows scroll lock (via VBA for advanced users)

The Scroll Lock key does not freeze or protect rows. It changes what the arrow keys do, which is why it is often mistaken for a row lock.

Question Answer
What does Scroll Lock do in Excel? With it on, the arrow keys scroll the sheet instead of moving between cells
How do I see if it is on? Scroll Lock appears in the Excel status bar; right-click the status bar and tick Scroll Lock if the indicator is hidden
How do I turn it off? Press ScrLk, or open the On-Screen Keyboard from Settings > Accessibility > Keyboard in Windows 11 and select ScrLk
Which VBA setting really keeps people in certain rows? ActiveSheet.ScrollArea = "A1:F200" from Method 5; cells outside the range cannot be selected
Which setting keeps header rows on screen? Freeze Panes, by hand (Methods 1 and 2) or with ActiveWindow.FreezePanes = True

If the arrow keys suddenly move the whole sheet, turn off Scroll Lock in Excel before trying any freeze option.

Method 6: Protect the worksheet to prevent changes in locked rows

Every cell is marked Locked by default, but the setting only takes effect once the sheet is protected. To lock only certain rows, unlock everything first, then lock those rows.

  1. Select Select All (the triangle above row 1), press Ctrl + 1, open the Protection tab, clear Locked and select OK.
  2. Select the row numbers of the rows to lock, for example rows 1 to 3.
  3. Press Ctrl + 1 again, tick Locked on the Protection tab and select OK.
  4. Select Review > Protect Sheet.
  5. In Allow all users of this worksheet to, tick only what others may do, such as Select unlocked cells, Insert rows or Sort.
  6. Type a password in Password to unprotect sheet if you want one, select OK and retype it to confirm.
  7. Try typing in a locked row. Excel refuses the edit and shows a protection message.

Sheet protection stops accidental edits but is not a security feature. Keep the password safe, because a lost password locks you out of the protected cells too. For formula-only locks and Allow Edit Ranges, lock individual cells in Excel with the same Format Cells setting.

Lock rows in Excel with the Locked box on the Protection tab
Press Ctrl + 1 to reach this tab; Locked has no effect until Review > Protect Sheet is turned on. (Image: Microsoft)

How to unfreeze rows in Excel

  1. Select the View tab.
  2. Select Freeze Panes > Unfreeze Panes to release frozen rows and columns.
  3. Select Split again on the View tab if a split is active.
  4. Select Review > Unprotect Sheet and enter the password to remove sheet protection.

How to repeat header rows when printing in Excel

Frozen rows only affect the screen. To print header rows at the top of every page, set print titles.

  1. Select Page Layout > Print Titles in the Page Setup group.
  2. On the Sheet tab, click in Rows to repeat at top.
  3. Type $1:$1 for row 1, or $1:$3 for rows 1 to 3.
  4. Select OK and check the result in print preview.
Repeat header rows when printing in Excel with Print Titles
Print Titles sits in the Page Setup group of the Page Layout tab and opens the Sheet tab settings. (Image: Microsoft)

How to freeze rows in Excel on Mac, iPad and the web

Platform Freeze the top row Freeze several rows
Excel for Windows View > Freeze Panes > Freeze Top Row Select the row below, then View > Freeze Panes > Freeze Panes
Excel for Mac View > Freeze Top Row Select the row below, then View > Freeze Panes
Excel for the web View > Freeze Panes > Freeze Top Row Select the row below, then View > Freeze Panes > Freeze Panes
Excel on iPad View > Freeze Panes, then the top-row option Select the row below, then View > Freeze Panes > Freeze Panes
Excel on iPhone Tap …, then Home > View > Freeze Panes Select the row below first, then the same path
Freeze rows in Excel on Mac from the View tab buttons
Excel for Mac shows Freeze Panes, Freeze Top Row and Freeze First Column as separate View tab buttons. (Image: Microsoft)

Practical tips for locking rows in Excel

Tip Why it helps
Scroll to the top before freezing Freeze Panes locks the rows visible above the selection, not hidden ones
Unfreeze before choosing a new freeze line Changing the selection does not move an existing freeze
Combine freeze and protection for shared files Headers stay visible and cannot be overwritten
Tick Insert rows when protecting a data list People can add rows without unprotecting the sheet
Protect Delete rows together with Insert rows If only deletion is blocked, users can insert rows they cannot delete
Set print titles separately Frozen rows do not repeat on printed pages
Keep freezes short on laptops A tall frozen block leaves little room for the scrolling area

How to tell if rows are frozen in Excel

  1. Look for a slightly thicker border under the last frozen row.
  2. Scroll down with the mouse wheel; frozen rows stay put while the rest moves.
  3. For protection, open the Review tab. Unprotect Sheet in place of Protect Sheet means the sheet is protected.

Common troubleshooting: Excel freeze panes not working

Freeze Panes is greyed out

The sheet is not in Normal view.

  1. Select View > Normal.
  2. Select Freeze Panes again.

The wrong rows are frozen

The selection or scroll position was off when the freeze was applied.

  1. Select View > Freeze Panes > Unfreeze Panes.
  2. Scroll to the top of the sheet.
  3. Select the row directly below the last row to lock and choose Freeze Panes again.

There is no View tab or Freeze Panes button

Excel Starter does not support every feature.

  1. Open the file in a full Excel edition or in Excel for the web.
  2. Select View > Freeze Panes there.

Arrow keys move the whole sheet instead of the cell

Scroll Lock is on.

  1. Check the status bar for Scroll Lock.
  2. Press ScrLk, or use the On-Screen Keyboard's ScrLk key.

Cells outside a range cannot be selected

A VBA ScrollArea is set on the sheet.

  1. Press Alt + F11 and run the ClearScrollArea macro from Method 5.
  2. Or ask the file owner to remove the macro that sets the scroll area.

Locked rows can still be edited

The sheet is not protected, or those cells had Locked cleared.

  1. Select the rows, press Ctrl + 1 and tick Locked on the Protection tab.
  2. Select Review > Protect Sheet and select OK.

How to lock rows in Excel FAQ

How do I lock a row in Excel so it doesn't move when scrolling?

Select View > Freeze Panes > Freeze Top Row to keep row 1 fixed. For any other set of top rows, select the row just below them and choose View > Freeze Panes > Freeze Panes. The rows above the selection stay on screen.

How do I freeze the top 3 rows in Excel?

Scroll to the top, select row 4 by clicking its row number, then select View > Freeze Panes > Freeze Panes. Rows 1 to 3 stay visible, and a thicker border appears under row 3.

How do I freeze rows and columns at the same time?

Select the cell below the rows and to the right of the columns you want fixed, then choose View > Freeze Panes > Freeze Panes. Cell B2 freezes row 1 and column A; D5 freezes rows 1 to 4 and columns A to C.

Can I freeze a row in the middle of a sheet?

No. A freeze always starts at the top row and first column. To keep a middle section in view, use View > Window > Split, which gives two panes that scroll independently, or scroll that section to the top before freezing.

How do I lock rows in Excel so they cannot be edited?

Clear Locked for the whole sheet in Format Cells, tick Locked only for the rows to protect, then select Review > Protect Sheet. Excel blocks edits to those rows until someone unprotects the sheet, with the password if one was set.

Why is Freeze Panes greyed out in Excel?

Freeze Panes is unavailable outside Normal view. Select View > Normal, then try Freeze Panes again. If there is no View tab at all, the file is open in Excel Starter, which does not support every feature.

How do I unfreeze rows in Excel?

Select View > Freeze Panes > Unfreeze Panes. That removes every frozen row and column on the sheet at once. A split is removed separately by selecting View > Split again.

Do frozen rows repeat when printing?

No. Freezing only changes the screen. To print header rows on every page, select Page Layout > Print Titles and enter a range such as $1:$1 in Rows to repeat at top on the Sheet tab.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *