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

by Allen Wyatt
(last updated April 25, 2019)


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


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 Office 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. ...


Allowing Only Form Field Changes

Word allows you to create forms that other people can use to enter information. One of the last steps normally taken with ...

Discover More

Controlling Sorting Order

When you sort information either in a table or the body of you document, Word follows a very specific set of rules to do ...

Discover More

Controlling the Bold Text Attribute

When processing a document in a macro, you may need to make some of your text bold. It's easy to do using the Bold ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Trouble Recording Paste Special Formula

Sometimes, when you upgrade to a new version of Excel, you could run into a problem recording macros that you had no ...

Discover More

Storing a User's Location before Running a Macro

Macros are often used to process information in a workbook. If your macro makes changes in what is selected in the ...

Discover More

Finding the Last-Used Cell in a Macro

Ever wonder what the macro-oriented equivalent of pressing Ctrl+End is? Here's the code and some caveats on using it.

Discover More

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

View most recent newsletter.


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 2?

2019-04-01 02:50:22


Thanks @Willy Vanhaelen
I understand the usage of the with block when referring to a number of properties; I thought I was missing something with only one statement.


2019-03-29 12:21:33

Willy Vanhaelen

In Escel's VBA Editor Press [F1] and type With: you get ample information.

You are quite right that in the second macro it has no sence to use With ... End With.

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

is exactly the same as:

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

But in this example for instance it is beneficial to use With ... End With:

With Selection.Offset(0, -1)
    If Not .Comment Is Nothing Then
        A = MsgBox(.Comment.Text, vbOKCancel, "Delete comment?")
        If A = vbOK Then .Comment.Delete
    End If
End With

Although you have 2 lines extra the lines between With and End With are much shorter and easier to write and the code executes slightly faster.

2019-03-24 21:55:17


What is the reason for the with block, containing statements not relating to the Application object.

In the second example, only one method of the object is used, possibly making the with block redundant.

Is there any benefit to this?

2019-03-20 05:30:42


If, for example, column C is the leftmost visible column when this macro is run, columns A and B remain unseen. It would seem that

.Goto Range("A1")

is needed before selecting H1 to ensure that column A is included in the freeze pane. Particularly if one is freezing some rows at the top as well.

2014-12-10 05:53:03


...Huh, I didn't know GoTo Range was a thing. Nice to know.

Like Gary I have used ScrollColumn in the past, but this sounds faster.

2014-12-08 04:53:30

Gary Allen

One slight variation on this that I have found really helpful is to combine the scroll function with a named cell (in the example below, cell Z1 is named "NAME").

This means that you can ensure the right cells are shown, even if additional columns are inserted into the sheet (so if the information you had in Z is now in AA or later).

ActiveWindow.FreezePanes = False
ActiveWindow.FreezePanes = True
myCol = Range("NAME").Column
ActiveWindow.ScrollColumn = myCol

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

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.