Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Displaying a Set Column Range.
Written by Allen Wyatt (last updated January 20, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
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, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Displaying a Set Column Range.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
If you have trouble seeing the information presented in a worksheet, you can use Excel's zooming capabilities to ease the ...
Discover MoreIf you are using a mouse that has a center wheel, you can use the wheel to zoom in and out of your work. This tip shows ...
Discover MoreTired of shared workbooks opening at some strange zoom factor that makes viewing your data difficult? Here's how to make ...
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 © 2024 Sharon Parq Associates, Inc.
Comments