Skip to footer content
EXCEL TOOLS

How to Pin a Row in Excel: 5 Methods That Actually Work

Written by the team at Iron Software


If you’ve ever scrolled down a long spreadsheet and lost track of which column is which, you already know the problem. Pinning or “freezing” a row in Excel keeps your header row locked in place while everything else scrolls freely. This freezing capability is a key feature in Excel for keeping important data visible while scrolling, helping you manage large spreadsheets more efficiently.

The fastest way: Click any cell in row 2, go to View → Freeze Panes → Freeze Top Row. Done. Row 1 is now pinned. This ensures your headers remain visible as you scroll through your data.

That’s the short answer. But depending on your version of Excel, your specific layout, or whether you need to freeze multiple rows, there’s a bit more nuance. This guide covers every method from the one-click ribbon approach to keyboard shortcuts, VBA macros, and a few edge cases that the basic tutorials always skip. *

Table of Contents

  1. What "Pinning a Row" Actually Means in Excel
  2. Method 1: Freeze the Top Row (Ribbon — Fastest)
  3. Method 2: Freeze Multiple Rows at Once
  4. Method 3: Keyboard Shortcut for Freeze Panes
  5. Method 4: Freeze Rows and Columns Simultaneously
  6. Method 5: VBA Macro to Freeze a Row Automatically
  7. How to Unfreeze Rows in Excel
  8. Common Issues and Troubleshooting
  9. For Developers: Freeze Rows Programmatically with IronXL *

What "Pinning a Row" Actually Means in Excel

In Excel's menus, the pin feature goes by the name Freeze Panes. This feature allows you to keep specific rows fixed at the top of your worksheet. These two terms mean the same thing in everyday conversation: locking a row (or rows) so they stay visible as you scroll down.

When a row is frozen, a thin dark line appears beneath it, separating the locked section from the scrollable area. The frozen rows always remain visible as you navigate through your spreadsheet, sitting at the top of the screen, no matter how far down you scroll.

You can choose to freeze specific rows to keep important information fixed while scrolling, making it easier to manage large spreadsheets.

Quick tip: Freezing is a display-only setting that affects navigation alone. Your data, formulas, and print output stay exactly as they are. *

Method 1: Freeze the Top Row (Ribbon — Fastest)

This is the method you want 90% of the time. If your headers are in row 1, this is a single click.

Steps:

  1. Open your spreadsheet in Excel.
  2. Select the View tab in the ribbon at the top.

  3. In the Window group, click the Freeze Panes button.

  4. From the Freeze Panes dropdown, select Freeze Top Row.

That’s it. A thin line appears under row 1, and it will stay put while you scroll. This method freezes the row you want to keep visible at the top.

Note: If you select any cell in row 2 before clicking the Freeze Panes button, Excel will freeze row 1.

Who this works for: Anyone whose column headers are in row 1 which covers the vast majority of standard spreadsheet setups.

Who this doesn’t work for: If your headers start on row 3 or row 4 (because you have a company logo or title block above them), this method will freeze the wrong row. For that situation, use Method 2 below.

How to Pin a Row in Excel: 5 Methods That Actually Work: Image 1 - View tab ribbon with the Freeze Panes dropdown open


Method 2: Freeze Multiple Rows at Once

Need to lock your first three rows? Or freeze a header block that spans rows 1–5? Excel handles this cleanly, and you can freeze more than one row at a time. If you want to freeze a couple of rows and columns together, Excel’s Freeze Panes feature lets you do both simultaneously. Here’s a quick tip: to freeze multiple rows or columns, always select the cell just below and to the right of the last row or column you want to keep visible.

The rule: Click the first row you don’t want to freeze. Excel will lock everything above your selection.

Steps:

  1. Click on the row number (or any cell) in the first row that should scroll freely. To freeze more than one row, select the row below the last row you want frozen.

    • Example: To freeze rows 1–3, click anywhere in row 4.
  1. Go to View → Freeze Panes → Freeze Panes (the first option in the list, not “Freeze Top Row”).

All rows above your selected row are now frozen.

How to Pin a Row in Excel: 5 Methods That Actually Work: Image 2 - Row selector with row 4 highlighted, and the Freeze Panes menu open to the “Freeze Panes” option

Note: To freeze multiple rows, follow these steps: click on the row number below the rows you want to freeze before navigating to the View tab and selecting Freeze Panes. Ensure you select the correct row to avoid freezing the wrong section. Here are some tips: double-check your selection before applying Freeze Panes, and remember you can freeze a couple of rows and columns together by selecting the appropriate cell. This will help you keep important data visible and improve your workflow.

Important distinction: “Freeze Top Row” always freezes row 1, regardless of where your cursor is. “Freeze Panes” freezes everything above your current selection. When in doubt, use “Freeze Panes.” *

Method 3: Keyboard Shortcut for Freeze Panes

Excel uses a reliable key sequence for freezing rows that gets you there without touching the mouse. Make sure to follow the steps below carefully to ensure the correct rows are frozen.

Shortcut sequence (Windows):

Alt → W → F → F
Alt → W → F → F
Alt → W → F → F
$vbLabelText   $csharpLabel

Press each key in sequence (not simultaneously):

  • Alt — activates the ribbon keyboard navigation
  • W — opens the View tab
  • F — opens the Freeze Panes menu
  • F — selects “Freeze Panes”

For Freeze Top Row specifically:

Alt → W → F → R
Alt → W → F → R
Alt → W → F → R
$vbLabelText   $csharpLabel

For Freeze First Column:

Alt → W → F → C
Alt → W → F → C
Alt → W → F → C
$vbLabelText   $csharpLabel

How to Pin a Row in Excel: 5 Methods That Actually Work: Image 3 - Excel ribbon with the keyboard shortcut letters (Alt key hints) overlaid, demonstrating Freeze Panes

Mac users: There’s no equivalent Alt-key shortcut on Mac. The closest approach is using the menu: View → Freeze Rows & Columns (Mac Excel uses slightly different terminology but works identically). You can also set a custom keyboard shortcut via System Settings → Keyboard → Keyboard Shortcuts → App Shortcuts. *

Method 4: Freeze Rows and Columns Simultaneously

Sometimes you need both your header row and your leftmost column (like employee IDs or account numbers) to stay visible when scrolling in both directions. This method is useful for freezing columns as well as rows, especially when you want to freeze a couple of rows and columns together. Excel handles this in one move.

Steps:

  1. Select the cell just below the last row and to the right of the last column you want to freeze. This is how you select freeze panes for multiple rows and columns.
  • Example: To freeze row 1 and column A, click cell B2.
  • To freeze rows 1–2 and columns A–B, click cell C3.
  1. Go to View → Freeze Panes → Freeze Panes.

Excel will freeze everything above and to the left of your selected cell, keeping those rows and columns fixed and visible as you scroll. You’ll see two freeze lines, one horizontal, one vertical.

Note: As an alternative, you can use split panes to view different parts of your worksheet at the same time. Split panes create separate window sections, allowing you to scroll each section independently.

Practical use case: Financial models, inventory sheets, and project trackers often benefit from this. Freezing column A (names or IDs) plus row 1 (headers) means scrolling right or down never leaves you guessing what you’re looking at. *

Method 5: VBA Macro to Freeze a Row Automatically

If you manage multiple spreadsheets and want to apply freeze settings automatically say, every time a file opens, a simple VBA macro can handle it. This is particularly useful if you’re distributing workbooks to colleagues and want the view settings baked in.

How to set this up:

  1. Press Alt + F11 to open the VBA editor.

  2. In the left panel, double-click ThisWorkbook (under your file name).

  3. Paste the following code:
Private Sub Workbook_Open()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Activate
        ws.Rows("2:2").Select
        ActiveWindow.FreezePanes = True
    Next ws
    ThisWorkbook.Worksheets(1).Activate
End Sub
Private Sub Workbook_Open()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Activate
        ws.Rows("2:2").Select
        ActiveWindow.FreezePanes = True
    Next ws
    ThisWorkbook.Worksheets(1).Activate
End Sub
Option Strict On



Private Sub Workbook_Open()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Activate()
        ws.Rows("2:2").Select()
        ActiveWindow.FreezePanes = True
    Next ws
    ThisWorkbook.Worksheets(1).Activate()
End Sub
$vbLabelText   $csharpLabel
  1. Close the VBA editor and save your file as .XLSM (macro-enabled workbook).

This macro runs automatically whenever the workbook opens and freezes row 1 across all sheets.

To freeze a specific row only (not all sheets):

Sub FreezeRow()
    Sheets("Sheet1").Activate
    ActiveSheet.Rows("2:2").Select
    ActiveWindow.FreezePanes = True
End Sub
Sub FreezeRow()
    Sheets("Sheet1").Activate
    ActiveSheet.Rows("2:2").Select
    ActiveWindow.FreezePanes = True
End Sub
Sub FreezeRow()
    Sheets("Sheet1").Activate()
    ActiveSheet.Rows("2:2").Select()
    ActiveWindow.FreezePanes = True
End Sub
$vbLabelText   $csharpLabel

Run this manually via Alt + F8 → Select “FreezeRow” → Run.

Note: Macros require you to save as .XLSM and may trigger security warnings depending on your organization’s settings. If your company disables macros, stick with Methods 1–4.

If you need more advanced automation or run into issues with VBA, consider consulting an Excel expert for personalized assistance and troubleshooting. *

How to Unfreeze Rows in Excel

To remove the frozen row(s), go to the View tab, click the Freeze Panes button, and select Unfreeze Panes.

Unfreezing is even easier than freezing. No matter how many rows or columns you’ve frozen:

  1. Go to View → Freeze Panes.
  2. The first option will now read Unfreeze Panes (it replaces “Freeze Panes” when something is already frozen).

  3. Click it. Everything unfreezes instantly.

Keyboard shortcut to unfreeze: Alt → W → F → F (same as freezing — Excel toggles based on the current state). *

Common Issues and Troubleshooting

"Freeze Top Row" is grayed out

This almost always means one of two things:

  • You're in cell editing mode. Press Escape first, then try again.
  • The workbook is protected. Go to Review → Unprotect Sheet (you'll need the password if one was set). Freeze settings can't be changed on protected sheets.
    • *

The freeze line appears in the wrong place

This happens when you use "Freeze Panes" (not "Freeze Top Row") while your cursor is in an unexpected position. Solution: Unfreeze all panes first, then carefully select the correct cell before re-applying. *

Frozen rows don't print and the header disappears on page 2+

Freezing panes and printing repeating headers are two separate features. Freezing only affects the screen. To repeat a row on every printed page:

  1. Go to Page Layout → Print Titles.
  2. Click in the "Rows to repeat at top" box.

  3. Click the row number(s) on your spreadsheet.
  4. Click OK. *

The freeze line moves when sorting or filtering data

It shouldn't, freeze panes are anchored to row/column positions, not to specific cell content. If it seems to shift, the most likely cause is that you unfroze and re-froze at a different position. Unfreeze, sort your data, then re-apply the freeze.


The freeze line is visible but the row still scrolls

Check whether you're using Split instead of Freeze. The View tab has both options and they look similar. A split creates two independently scrollable panes, rows above the split can still move. Click View → Split to toggle it off, then use Freeze Panes instead. *

Excel Online / Microsoft 365 web version

The web version of Excel supports Freeze Panes, but the menu location is slightly different. Look under View → Freeze Rows & Columns (or View → Freeze Panes depending on your browser and account type). Not all keyboard shortcuts work in the browser version. *

For Developers: Freeze Rows Programmatically with IronXL

If you’re building a .NET application that generates Excel files, reports, exports, dashboards and you want freeze panes applied automatically without requiring users to set them manually, IronXL makes this straightforward.

IronXL is a C# Excel library that lets you create, read, and modify Excel files without requiring Microsoft Office to be installed on the server. Freeze pane settings are applied at the worksheet level, allowing you to easily share spreadsheets with freeze features like 'Freeze Top Row' or 'Freeze Panes' already set.

Example: Freeze the top row on an exported report

using IronXL;
// Load or create a workbook
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.DefaultWorkSheet;
// Add header row
sheet["A1"].Value = "Order ID";
sheet["B1"].Value = "Customer";
sheet["C1"].Value = "Amount";
sheet["D1"].Value = "Date";
// Populate data rows
for (int i = 2; i < = 100; i++)
{
    sheet[$"A{i}"].Value = i - 1;
    sheet[$"B{i}"].Value = $"Customer {i - 1}";
    sheet[$"C{i}"].Value = (i * 15.50).ToString("C");
}
// Freeze the top row so headers stay visible when scrolling
sheet.CreateFreezePane(0, 1); // column split = 0, row split = 1
// Save the file
workbook.SaveAs("OrderReport.xlsx");
using IronXL;
// Load or create a workbook
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.DefaultWorkSheet;
// Add header row
sheet["A1"].Value = "Order ID";
sheet["B1"].Value = "Customer";
sheet["C1"].Value = "Amount";
sheet["D1"].Value = "Date";
// Populate data rows
for (int i = 2; i < = 100; i++)
{
    sheet[$"A{i}"].Value = i - 1;
    sheet[$"B{i}"].Value = $"Customer {i - 1}";
    sheet[$"C{i}"].Value = (i * 15.50).ToString("C");
}
// Freeze the top row so headers stay visible when scrolling
sheet.CreateFreezePane(0, 1); // column split = 0, row split = 1
// Save the file
workbook.SaveAs("OrderReport.xlsx");
Imports IronXL

' Load or create a workbook
Dim workbook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
Dim sheet As WorkSheet = workbook.DefaultWorkSheet

' Add header row
sheet("A1").Value = "Order ID"
sheet("B1").Value = "Customer"
sheet("C1").Value = "Amount"
sheet("D1").Value = "Date"

' Populate data rows
For i As Integer = 2 To 100
    sheet($"A{i}").Value = i - 1
    sheet($"B{i}").Value = $"Customer {i - 1}"
    sheet($"C{i}").Value = (i * 15.5).ToString("C")
Next

' Freeze the top row so headers stay visible when scrolling
sheet.CreateFreezePane(0, 1) ' column split = 0, row split = 1

' Save the file
workbook.SaveAs("OrderReport.xlsx")
$vbLabelText   $csharpLabel

The CreateFreezePane(colSplit, rowSplit) method takes two parameters: the number of columns to freeze from the left, and the number of rows to freeze from the top. To freeze just the header row, pass (0, 1). To freeze both the header row and the first column, pass (1, 1).

The resulting file opens in Excel with the freeze already applied, users don’t need to set it themselves, which is especially helpful when distributing reports to non-technical stakeholders.

Want to explore IronXL further? It handles everything from cell formatting and formulas to charts, password protection, and file format conversion between XLSX, XLS, CSV, and more. You can find full documentation and a free trial at IronXL website.

For more resources, visit the IronXL site to access guides, ask questions, and share your solutions with the developer community. We also encourage you to join the Excel developer community to connect with others, share tips, and get support for your projects.

Summary: Which Method Should You Use?

| Situation | Best Method | | --- | --- | | Freeze row 1 (standard headers) | Method 1 — Freeze Top Row via ribbon | | Freeze rows 1–3 or any multi-row header | Method 2 — Click row 4, then Freeze Panes | | Keep hands on keyboard | Method 3 — Alt → W → F → R | | Freeze a row AND a column together | Method 4 — Click cell below+right, then Freeze Panes | | Apply freeze automatically in a distributed workbook | Method 5 — VBA macro | | Building a .NET app that exports Excel files | IronXL CreateFreezePane() |

Freeze Panes is one of those features that feels invisible until you use it and once you do, it’s hard to go back to scrolling blind. The ribbon method (Method 1) covers most everyday situations, and Method 2 handles anything more complex. Everything else in this guide is for edge cases and power users.

If you have a question about which method to use, consider the tips provided in this guide. A thoughtful approach to freezing panes can help you avoid common pitfalls. Tip: Freezing too many rows can limit the visible area you have to work with, especially on smaller screens.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me