Excel Practice Test

โ–ถ

Picture this. You drop a fresh dataset into Excel, hit save, and half the columns show #### instead of numbers. Rows squash text into a single unreadable strip. Manually dragging every column boundary works for a tiny sheet, but try doing that across forty columns and 5,000 rows. Tedious, slow, and prone to mistakes.

AutoFit is the fix. It tells Excel to size each column or row to the longest visible content automatically. Two clicks, a keyboard shortcut, or a single VBA line, and your sheet stops looking like a wall of hashes. We will walk through every AutoFit method that ships with modern Excel, including the mouse trick most users miss, the ribbon path, the keyboard combo for power users, and the macro you can attach to a button when you want one-click formatting across the workbook.

You will also learn why AutoFit sometimes refuses to work, how merged cells and wrapped text break it, and the exact order of operations to apply when a sheet has mixed content. By the end, resizing in Excel will feel like a reflex rather than a chore. Quick warning before we dive in: a few of these tricks are version-specific. We will flag macOS and Excel Web differences along the way so you do not waste five minutes hunting a menu that does not exist on your build.

AutoFit at a Glance

2
Clicks via ribbon Home > Format > AutoFit
Alt H O I
Keyboard shortcut for AutoFit Column Width
Alt H O A
Keyboard shortcut for AutoFit Row Height
8.43
Default Excel column width in characters

What AutoFit Actually Does

AutoFit measures the widest piece of content in a column (or the tallest item in a row) and snaps the boundary to match. It uses the font, font size, and any cell formatting applied at the time you run it. Change the font from Calibri 11 to Arial 14 later, and the column will look cramped again until you re-run AutoFit. The behaviour is deterministic, which is reassuring once you understand it: AutoFit never guesses, it measures.

One subtle point. AutoFit Column Width does not consider wrapped text. If you turned on Wrap Text and a paragraph is broken across three visual lines, AutoFit will still size the column to the longest single unbroken string in the cell. That is why people often think AutoFit is broken when the real culprit is wrap. We will untangle this combination later.

Rows behave differently. AutoFit Row Height respects wrapped content, so once a column is narrow and wrap is on, AutoFit Row Height grows the row to show every line. The order matters: set column width first, then AutoFit row height. Reverse the order and you will be running both commands twice.

Select the entire sheet with Ctrl + A, then double-click the boundary between any two column headers. Excel AutoFits every column on the sheet in a single move. The same trick on a row boundary AutoFits every row. Most users only ever drag one column at a time and miss this five-second shortcut. Teach it to one colleague today and they will thank you tomorrow.

The Five Ways to AutoFit Columns and Rows

You can reach AutoFit from the mouse, the ribbon, the keyboard, the Name Box, or VBA. Each method has a moment when it is the fastest tool. Drag-to-AutoFit is best when you are already moving the mouse. The ribbon path is friendliest for new users. Keyboard shortcuts pay off when you AutoFit dozens of times per session. VBA wins for repetitive workbooks and templates.

The trick is knowing all five and switching between them on instinct. The ribbon command lives under Home > Cells > Format. Open it once and you will see entries for Row Height, Column Width, AutoFit Row Height, AutoFit Column Width, and Default Width. The two AutoFit entries are what you want. Pin the Format dropdown to your Quick Access Toolbar if you use it constantly.

If you have already selected a column or row, right-click the header and the same options appear in the context menu. This is the path many keyboard-averse users find on their own. It works in every Excel version since 2007, so if a colleague is on an older edition, this is the safest route to share.

Method Cheat Sheet

๐Ÿ”ด Double-Click Boundary

Hover the right edge of a column header until the cursor becomes a double arrow, then double-click. Instantly AutoFits that column.

๐ŸŸ  Ribbon Path

Home > Format > AutoFit Column Width (or Row Height). Works on whatever cells are currently selected.

๐ŸŸก Keyboard Shortcut

Alt H O I for column width. Alt H O A for row height. Press the letters in sequence, not together.

๐ŸŸข Select-All + Double-Click

Ctrl + A then double-click any column boundary. Resizes the entire sheet in one move.

๐Ÿ”ต VBA Macro

Cells.EntireColumn.AutoFit and Cells.EntireRow.AutoFit. Attach to a button or run on workbook open.

Step-by-Step: AutoFit Column Width

Open the worksheet you want to resize. Click the column header letter to select the entire column, or drag across multiple headers to select several at once. To grab every column, click the small triangle in the top-left corner above row 1 and to the left of column A, or use Ctrl + A.

With your selection live, go to the Home tab on the ribbon. In the Cells group you will see Insert, Delete, and Format. Click Format. A dropdown opens with Cell Size at the top. Choose AutoFit Column Width. Excel resizes every selected column to the longest visible value.

Prefer the keyboard? Tap Alt, then H, then O, then I. The letters light up on the ribbon as you press them, which is handy when you forget the sequence. Release Alt at any time and the chord resets. Hold down Alt the whole time if you prefer the legacy behaviour from Excel 2003.

For mouse users, the fastest move is to hover over the boundary between two column headers. The cursor changes to a vertical line with arrows on both sides. Double-click. The column to the left of the boundary AutoFits. Repeat across the sheet, or select all first to do them in bulk. This double-click trick is the single most underused feature in Excel and the one most likely to impress a new colleague.

AutoFit by Excel Version

๐Ÿ“‹ Excel 365 / 2021

Identical paths: Home > Format > AutoFit Column Width. Keyboard shortcut Alt H O I works everywhere. Power users can also use the search bar (Alt + Q) and type AutoFit to jump straight to the command.

๐Ÿ“‹ Excel 2016 / 2019

Same ribbon position. The only difference is the search bar (Tell Me) lives further right. AutoFit behaviour is unchanged and every macro shown in this guide runs without modification.

๐Ÿ“‹ Excel for Mac

Home > Format > AutoFit Column Width is identical. Keyboard shortcut differs: use Cmd + A to select all, then double-click any column boundary. The Alt-H sequence does not work on macOS, but you can record a macro and assign your own Cmd-shifted shortcut.

๐Ÿ“‹ Excel Web

AutoFit is supported. Right-click a column header, choose AutoFit Column Width. The ribbon path is shorter: Home > Format > AutoFit. VBA macros do not run in the browser, so save complex auto-formatting for the desktop client.

Step-by-Step: AutoFit Row Height

Row AutoFit is the partner to column AutoFit, and it is most useful when text wrap is on. Select the row numbers you want to resize. Right-click and choose AutoFit Row Height, or use Home > Format > AutoFit Row Height. Excel grows or shrinks every selected row to fit its tallest visible content.

The keyboard route is Alt, H, O, A. Easy to remember if you treat the H as Home and the O as Format. The double-click trick also works on rows. Hover the boundary between two row numbers in the leftmost column of the worksheet. The cursor becomes a double arrow. Double-click and the row above the boundary AutoFits. Combine with Ctrl + A first to AutoFit every row at once.

If a row stubbornly stays a fixed height after AutoFit, the culprit is usually a manually set height. Excel respects user-set dimensions and remembers them. Right-click the row header, pick Row Height, set it back to the default 15, then run AutoFit Row Height again to let Excel pick the right value. This two-step reset is the most common fix on the Microsoft community forums, but few users know it.

AutoFit with VBA: The One-Click Macro

If you build the same report every week, manual AutoFit gets old. A two-line macro fixes that forever. Press Alt + F11 to open the Visual Basic Editor. Insert a new module via Insert > Module. Paste the following:

Sub AutoFitEverything()
    Cells.EntireColumn.AutoFit
    Cells.EntireRow.AutoFit
End Sub

Close the editor. Press Alt + F8, select AutoFitEverything, click Run. Every column and row in the active sheet snaps to fit. Save the workbook as .xlsm to keep the macro. For a button, go to the Developer tab, click Insert, choose a Form Control button, draw it on the sheet, and assign the macro. One click and the entire sheet is formatted.

Want it across every sheet in a workbook? Wrap the macro in a loop:

Sub AutoFitAllSheets()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Cells.EntireColumn.AutoFit
        ws.Cells.EntireRow.AutoFit
    Next ws
End Sub

This iterates every worksheet in the file. Perfect for a workbook with a tab for each month or region. Combine with the Workbook_BeforeSave event in ThisWorkbook to AutoFit automatically every time the file saves. Many corporate templates use this pattern. Just remember that the macro skips hidden sheets only if you add an If ws.Visible Then check, otherwise it touches them too.

AutoFit Pre-Flight Checklist

Selection covers the columns or rows you want to resize
Wrap Text is set the way you want before running row AutoFit
Merged cells are unmerged or replaced with Center Across Selection
No manually set row height blocking the resize
Filters are cleared if you want AutoFit to consider hidden rows
Font and zoom level are final before running AutoFit
Test Your Excel Skills

Common AutoFit Problems and Fixes

AutoFit looks like a single button, but it interacts with wrap, merges, filters, frozen panes, and even table objects in ways that can trip new users. Here are the issues that show up most often in support forums and the fastest way to clear each one. Bookmark this section; you will need it within a week of starting any new spreadsheet job.

Column will not resize past a certain width

Excel caps column width at 255 characters. If a single cell holds a 300-character paragraph and wrap is off, AutoFit will hit the ceiling. Turn on Wrap Text for that cell so the long content can flow across multiple lines. Then AutoFit Row Height to see all of it. If your data is consistently long strings, consider splitting them into multiple columns with Text to Columns first.

AutoFit Row Height shows only one line

Either Wrap Text is off, or the row has a manually fixed height. Confirm wrap is on (Home > Wrap Text). If the row still misbehaves, right-click the row, choose Row Height, type 15, hit OK. Now run AutoFit Row Height. The manual lock is gone and Excel can resize freely. This is a classic Excel quirk because the program treats any user-typed height as a sticky preference until you override it.

Columns in a table snap back after AutoFit

Excel Tables (Ctrl + T) sometimes refresh column widths when the table is updated. Right-click the table, choose Table > Convert to Range, AutoFit, then convert back if you need table features. Or set the table's PreserveColumnInfo property via VBA to keep custom widths. Many analysts simply work outside tables for this reason, but the structured-reference benefits usually outweigh the resize annoyance.

Pivot Table widths reset on refresh

Right-click anywhere in the PivotTable, choose PivotTable Options, and on the Layout & Format tab uncheck Autofit column widths on update. Now the widths you set stay set, even after refreshing the data. This single checkbox saves dashboard builders hours every quarter.

AutoFit Pros and Cons

Pros

  • Saves hours of manual column dragging on big datasets
  • Works identically across Windows, Mac, and Excel for the web
  • Plays nicely with macros for repeat formatting jobs
  • Built into every Excel version since 1997
  • Free to use; no add-in required

Cons

  • Ignores merged cells, leaving headers truncated
  • Capped at 255 characters per column width
  • Resets nicely-designed templates if run carelessly
  • Pivot Table refresh can override AutoFit results
  • Wrap Text and AutoFit Column Width interact in confusing ways

When to Use AutoFit vs Manual Widths

AutoFit is brilliant for working sheets, exploratory analysis, and any spreadsheet you build once and discard. The moment you start sharing files with non-technical users, the calculus changes. A column that AutoFits to fit the longest cell will move every time the underlying data changes. That can break printed layouts, mess with dashboards, and surprise readers who expect stable column widths.

For a polished dashboard or template, set widths manually after you AutoFit once. Round each column to a sensible round number (12, 15, 20 characters) and lock the column widths so Excel does not adjust them on refresh. PivotTables have an explicit setting for this, as we saw. For regular ranges, just resist the urge to run AutoFit on a finished design. A good rule: AutoFit early, lock late.

On the other hand, never hand-tune widths for an exported CSV report or an internal QA sheet. AutoFit it and move on. The five seconds you save compound across the year. Most analysts run AutoFit dozens of times per day without thinking about it, and so should you.

AutoFit and Print Layout

One small gotcha: AutoFit looks at on-screen rendering, which can differ from print rendering by a few pixels. After AutoFit, switch to Page Layout view (View > Page Layout) and check the columns are not cutting off the last character of any cell. If they are, nudge the column boundary one notch wider, or set the print scaling to Fit All Columns on One Page via Page Layout > Scale to Fit. This is the difference between a polished printed report and one that has half a phone number missing on every row.

Power Query and AutoFit

If your data lands in Excel via Power Query, the load destination defaults to an Excel Table. As soon as the table refreshes, custom column widths can revert. Either uncheck Preserve Column Sort/Filter/Layout in Query Properties, or run an AutoFit macro on the Workbook_AfterRefresh event. That keeps every refresh looking clean without manual intervention.

Excel Questions and Answers

What is the keyboard shortcut to AutoFit columns in Excel?

Press Alt, then H, then O, then I in sequence. The shortcut works on Excel for Windows in every version from 2007 onward. On Mac, select all (Cmd + A) and double-click any column boundary instead, because the Alt-H sequence is Windows-only.

Why is AutoFit not working in my Excel sheet?

Three common reasons. First, the row height is manually fixed. Right-click the row, set height to 15, then AutoFit again. Second, merged cells confuse AutoFit. Unmerge, AutoFit, then use Center Across Selection if you still want the visual merge. Third, the column has hit Excel's 255-character cap. Turn on Wrap Text to let the content flow over multiple lines.

How do I AutoFit every column in the entire workbook?

Use a short VBA macro. Open the VBA editor with Alt + F11, insert a module, and paste a For Each loop that iterates Worksheets and calls Cells.EntireColumn.AutoFit on each. Save the workbook as .xlsm. Run the macro with Alt + F8 whenever you want a one-click format for every sheet.

Does AutoFit work with merged cells?

No. AutoFit Column Width ignores merged cells when calculating width, so the merged header text often gets truncated even after AutoFit. The workaround is to unmerge, run AutoFit on the underlying data, then apply Center Across Selection via Format Cells > Alignment > Horizontal. That produces the same visual effect without breaking AutoFit.

How do I make AutoFit consider wrapped text?

AutoFit Column Width does not look at wrap. It sizes the column to the longest unbroken string. For wrapped content, set the column width manually (or AutoFit first, then narrow it), turn on Wrap Text, then run AutoFit Row Height. That order grows the row to display every wrapped line.

Why does my PivotTable column width reset after refresh?

Excel re-applies the PivotTable's stored widths on refresh by default. Right-click any cell in the PivotTable, pick PivotTable Options, and on the Layout & Format tab uncheck Autofit column widths on update. Then your manual or AutoFit widths persist through refreshes.

Can I AutoFit only specific columns instead of the whole sheet?

Yes. Click the header letter of the first column you want, hold Ctrl and click any other column headers to add them, then run AutoFit Column Width via Home > Format or the keyboard shortcut. Excel resizes only the selected columns and leaves the rest untouched.

Is there a way to AutoFit automatically every time the data changes?

Use a Worksheet_Change event in VBA. Open the sheet's code module via right-click on the tab > View Code, then write a Worksheet_Change subroutine that calls Target.EntireColumn.AutoFit. Now Excel resizes every time you edit a cell. Be aware it can slow down large workbooks because it runs after every change.
Try an Excel Practice Test

Wrapping Up

AutoFit is one of those features you only notice when it is missing. Spend an afternoon manually sizing columns across a hundred-tab workbook and you will fall in love with Alt H O I forever. Once you internalize the five paths (mouse, ribbon, keyboard, select-all double-click, VBA), you will move between them without thinking, picking whichever is fastest for the moment.

The deeper takeaway is that AutoFit is best used as a starting point, not a final layout. Run it to clean up imported data, then refine with manual widths for anything you intend to share or print. Lock down PivotTable widths so they survive refresh. Use Center Across Selection instead of merges to avoid the AutoFit-merge clash. Build a macro for sheets you re-format weekly so the work happens with one click.

Practice these moves on a real workbook today. Try the Ctrl + A then double-click combo. Record a macro for AutoFitEverything and bind it to a Quick Access Toolbar slot. Within a week the new muscle memory will save you a meaningful chunk of every Excel session. Your future self, staring at a column of #### at 4:55 on a Friday, will thank you.

One last tip most Excel books skip. If you frequently AutoFit the same columns to the same widths after a refresh, record a personal macro and store it in your Personal Macro Workbook (PERSONAL.XLSB). That way the macro is available across every file you open, not just the one you built it in. Assign a Quick Access Toolbar slot and you have one-click AutoFit for life, in every spreadsheet you ever touch, regardless of who originally created the workbook or where it came from. That single trick alone has saved me hours every single month.

โ–ถ Start Quiz