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


Displaying Letter Grades

Grading in schools is often done using numeric values. However, you may want to change those numeric values into letter ...

Discover More

Adding Table Columns to Columns with Merged Cells

Word's table editor allows you to modify the structure of tables in a wide variety of ways. If you want to add columns to ...

Discover More

Deleting All Footnotes

Tired of all those footnotes hanging on the bottom of each page in your document? You can get rid of them in one step, as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Easily Changing the Default Drive and Directory

Need a quick way to change the default drive and directory in a macro you are writing? Here's the commands to do it and a ...

Discover More

Displaying the Print Dialog Box in a Macro

Want to print a document by using a macro? One way is to display the Print dialog box and allow the user to interact with ...

Discover More

Disabling All Function Keys Except One

Disabling function keys is rather easy to do when you rely on the OnKey method in a macro. This tip looks at how you can ...

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 9 - 4?

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.