Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. 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: Positioning a Column on the Screen.

Positioning a Column on the Screen

Written by Allen Wyatt (last updated December 21, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


Riek encountered a problem while developing a macro that sets up the screen for user input. Columns A:G always need to stay on the screen, so his macro freezes those columns. He then issues a command to move to column Z to start input. This places columns T:Z to the right of the frozen columns A:G. What Riek really wants is for columns Z:AF to appear to the right of A:G, but he doesn't know how to accomplish that.

There are several ways that the desired results can be achieved. The first is to simply move "past" the desired target, and then move back to it, as in the following macro:

Sub GotoCol1()
    With Application
        ActiveWindow.FreezePanes = False
        Range("H1").Select
        ActiveWindow.FreezePanes = True
        .Goto Range("IV1")
        .Goto Range("Z1")
    End With
End Sub

The important code lines are those that use the Goto method. The first jump is to the last cell of the first row, and the second jump moves back to the true target, Z1. By moving in this way, column Z ends up just to the right of the frozen range, A:G.

While this works just fine, a better solution would be to use the Scroll parameter with the Goto method. Consider the following example:

Sub GotoCol2()
    ActiveWindow.FreezePanes = False
    Range("H1").Select
    ActiveWindow.FreezePanes = True
    Application.Goto Reference:=Range("Z1"), Scroll:=True
End Sub

The Scroll parameter is optional with the Goto method; it defaults to False. If you set it to True, then Goto scrolls through the window so that the upper-left corner of the target range (Z1) appears in the upper-left corner of the window.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10523) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Positioning a Column on the Screen.

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

Setting Row Height in a Macro

Macros can be used to change the formatting of your worksheet, if desired. One change you might want to make is to the ...

Discover More

Viewing Files of a Certain Type

When you choose to open a file, Word normally displays only those files that end with the .DOCX or .DOCM extensions. If ...

Discover More

Moving from Sheet to Sheet

Need to move quickly through the worksheets in a workbook? Learn the keyboard shortcuts and you can make short work of ...

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)

Displaying Worksheets in a Slideshow Fashion

Want to step through the worksheets in a workbook, displaying them like a slideshow? The macros provided in this tip can ...

Discover More

Macros Run Slower in Newer Excel?

If you run a macro you used in an older version of Excel on a newer system, it may seem like the macro runs slower. Here ...

Discover More

DOS from Macros

Need to run a DOS command from within one of your macros? The answer is the Shell command, described in this tip.

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}] (all 7 characters, in the sequence shown) 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 minus 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.