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

Configuring Spell Check for Internet Addresses

When writing technical documents, URLs are a common thing to include in your text. Normally Word will mark these as ...

Discover More

Can't Save Formatted AutoCorrect Entries

How you go about creating an AutoCorrect entry can be an important part of what you can do with that entry. Here's an ...

Discover More

Converting to Word 6.0 Format

Need to convert your document to a really old format previously used in Word? The solution may already be built into the ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development 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

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

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
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 nine more than 9?

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.