+ Reply to Thread
Results 1 to 6 of 6

Freeze panes in vba

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Freeze panes in vba

    I am using the following snippet of code to try and freeze the left 4 columns and the upper 4 rows
    Worksheets("Sheet1").Activate
    ActiveWindow.ScrollRow = 1
    ActiveWindow.ScrollColumn = StartPlace - 4
       
     ActiveWindow.FreezePanes = False
        With ActiveWindow
         10   .SplitColumn = StartPlace - 4
               .SplitRow = 5
            .FreezePanes = True
        End With
    End Sub
    Freeze panes works on the SplitRow = 4
    It does not appear to be working on SplitColumn = StartPlace-4 (= 2224) I have searched for a column which is not the one I needed that is Frozen but Have not found it.
    I have also tried adding another FreezePanes =True after row 10 still not working. I have attached a copy of the important part of the worksheet. Can some body show me where I have gone wrong?
    Attached Files Attached Files

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Freeze panes in vba

    Hello j_Southern,

    Please upload a sample Workbook with the relevant Code you have, as well as a "Before" and "After" Sheet showing us your desired outcome.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,466

    Re: Freeze panes in vba

    Select the first cell you want to be able to move and then freeze the panes. If you change your posted code snippet to this, I think it will work the way you want...
    Worksheets("Sheet2").Activate
    With ActiveWindow
      .ScrollRow = 1
      .ScrollColumn = 1
      .FreezePanes = False
      Range("E5").Select
      .FreezePanes = True
    End With

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Freeze panes in vba

    Thanks Rick for your interest. Your help has got me going, but left me with a puzzle.
    I slightly modified your code Because in fact the spread sheet is very large with 3000 columns. I want to freeze at the last 365 of these. So I changed to this:-
    Worksheets("Sheet2").Activate
    With ActiveWindow
      .ScrollRow = 1
      .ScrollColumn = 1
      .FreezePanes = False
     .Cells(5,LastCol).select
     .FreezePanes = True
    End With
    When the command button that fires this code, is pressed. Sheet1 is activated at "A5" And the upper rows are frozen, but no columns on the left. LastCol has the right, large, value
    John

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,466

    Re: Freeze panes in vba

    Quote Originally Posted by j_Southern View Post
    Thanks Rick for your interest. Your help has got me going, but left me with a puzzle.
    I slightly modified your code Because in fact the spread sheet is very large with 3000 columns. I want to freeze at the last 365 of these. So I changed to this:-
    Worksheets("Sheet2").Activate
    With ActiveWindow
      .ScrollRow = 1
      .ScrollColumn = 1
      .FreezePanes = False
     .Cells(5,LastCol).select
     .FreezePanes = True
    End With
    When the command button that fires this code, is pressed. Sheet1 is activated at "A5" And the upper rows are frozen, but no columns on the left. LastCol has the right, large, value
    John
    Sheet1 is activated???? The code says Sheet2 is being activated. Also, I am not sure why you are not getting an error with the code because the Cells(5, LastCol).Select should not have a dot in front of it.

  6. #6
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Freeze panes in vba

    Rick, Thanks again for your help. The code below is the code that was used ( I am sorry I published the wrong version)
    [CODE]Sub StopFrame(StartPlace)
    Worksheets("Sheet1").Activate
    With ActiveWindow
    .SplitRow = 6
    .SplitColumn = StartPlace
    .FreezePanes = False
    Cells(6, StartPlace).Select
    .FreezePanes = True
    End With
    End Sub
    [/CODE
    It behaves as I described before with the rows frozen but not the columns. The idea for the code came from googling "FreezePanes". I had not been aware of "Split" before but it seemed to be a good fit to use with FreezePanes .
    Can you help me a bit further?
    John

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro w/ Freeze panes keeps shifting where panes freeze on worksheet
    By sschwant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2015, 02:30 AM
  2. Freeze Panes - Can I freeze a specific set of cells?
    By Rosco88 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2013, 09:17 AM
  3. Freeze Panes - Freeze Tabs
    By samprince in forum Excel General
    Replies: 1
    Last Post: 01-23-2007, 05:16 PM
  4. Replies: 3
    Last Post: 11-27-2006, 05:24 PM
  5. Excel 2003 freeze panes won't freeze top row only
    By macbone2002 in forum Excel General
    Replies: 1
    Last Post: 05-31-2006, 11:10 AM
  6. Freeze Panes-When freeze panes is employed it leave a black line
    By peter.thompson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2006, 01:40 AM
  7. Freeze Panes-can you freeze more than one column
    By rexmann in forum Excel General
    Replies: 4
    Last Post: 06-09-2005, 11:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1