Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Freeze Pane in a macro (Excel 2002)

    Hi,

    I am using the ActiveWindow.FreezePanes=True in my macro and it seems to freeze the panes where it wants to. I have the active cell to A2 as I only want the first line frozen, but it seems to freeze the panes anywhere.

    Regards

    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    If your window already has frozen panes, setting ActiveWindow.FreezePanes = True will not change the frozen rows/columns to match the selected cell/row/column. You must unfreeze panes first, then freeze them again:

    ActiveWindow.FreezePanes = False
    ActiveWindow.FreezePanes = True

    Apart from that, setting ActiveWindow.FreezePanes = True should work the same as selecting Window | Freeze Panes... interactively.

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Hi Hans,

    I have not set any freeze panes, but in case there is some default I also did a ActiveWindow.FreezePanes=False, this made no difference, it still put the freeze pane near the end.

    Regards

    Mike

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Try qualifying it like this;

    Activewindow.ActiveSheet.[A2].Activate
    Activewindow.FreezePanes = True
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Cell A1 must be visible when freezing panes, otherwise it won't work as expected - the same holds when you freeze panes interactively. So try this:

    ' Make sure that cell A1 is visible
    Application.Goto Range("A1"), True
    ' Select cell A2
    Range("A2").Select
    ' Freeze panes
    ActiveWindow.FreezePanes = True

  6. #6
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Thanks Hans, that worked................... Regards Mike

  7. #7
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Thanks John

    That did not work, what I missed was having the cell visible, see Hans's response.

    Thanks for you input.

    Regards

    Mike

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Freeze Pane in a macro (Excel 2002)

    Odd, it worked for me.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •