Written by Allen Wyatt (last updated January 20, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
Let's say that you want to display a specific number of columns on a worksheet in the available window space. You can manually figure out the necessary width of each column and do the adjustments, or you can write a macro that will figure out, proportionally, how the width of each column should be adjusted to get the desired results.
An easier method, however, is to just adjust the zoom factor for a desired number of columns. This can be done manually by selecting the columns, displaying the View tab of the ribbon, and clicking the Zoom to Selection tool in the Zoom group.
If you want to do it programmatically, it is even easier. Right-click a worksheet tab (the one you want this macro to apply to) and then choose View Code from the resulting Context menu. Excel displays the Visual Basic Editor, and you should enter the following into the code window:
Private Sub Worksheet_Activate() Range("A1:L1").Select ActiveWindow.Zoom = True Range("A1").Select End Sub
This particular macro assumes that you want to view columns A through L in the window. It selects the range A1:L1, and then sets the zooming factor to display just that selection (the columns you want). Finally, it selects cell A1 and ends.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7805) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Displaying a Set Column Range.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Tired of shared workbooks opening at some strange zoom factor that makes viewing your data difficult? Here's how to make ...
Discover MoreExcel doesn't provide a keyboard shortcut that allows you to zoom in or out on your workbook. It is easy, however, to ...
Discover MoreIf you have trouble seeing the information presented in a worksheet, you can use Excel's zooming capabilities to ease the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-01-26 18:38:49
J. Woolley
Re. my previous comment below, I should have mentioned the AdjustRowHeights macro to adjust the height of selected rows with the same features as AdjustColumnWidths.
See https://sites.google.com/view/MyExcelToolbox/
2024-01-26 10:45:35
J. Woolley
My Excel Toolbox includes the AdjustColumnWidths macro to adjust the width of selected columns by a fixed increment or a proportional multiplier. Either choice includes an option to span the active window without changing the zoom factor. This macro supports Undo (Ctrl+Z).
See https://sites.google.com/view/MyExcelToolbox/
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments