Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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.

Displaying a Set Column Range

by Allen Wyatt
(last updated March 14, 2017)

4

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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7805) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Displaying a Set Column Range.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

First and Last Names in a Page Header

When you have a worksheet that includes a long list of names, you may want the first and last names on each page to appear in ...

Discover More

Getting Rid of All TA Fields

The first step in creating a table of authorities is to mark citations throughour your document. If you want to get rid of ...

Discover More

Jumping to a Specific Cell Using a Hyperlink

Excel allows you to define hyperlinks in your worksheets, and these can target specific cells on other worksheets. Here are ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Always Open at 100% Zoom

Tired of shared workbooks opening at some strange zoom factor that makes viewing your data difficult? Here's how to make sure ...

Discover More

Zooming In On Your Worksheet

If you have trouble seeing the information presented in a worksheet, you can use Excel's zooming capabilities to ease the ...

Discover More

Nifty Zooming

If 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 how ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 - 1?

2017-03-21 09:42:03

Martin Shingler

Neat. Thank you


2017-03-14 10:01:22

Gary Lundblad

I like it!

Gary


2013-04-18 13:34:38

nikx

Wonderful! Is it possible to run this code automatically each time a new worksheet is opened?

Thanks,

Nikx


2013-03-10 16:16:09

Just Dave

Great tip for setting the view with a macro. I had no idea it was that simple to do. This will come in handy for many of my workbooks.

Thanks


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.