+ Reply to Thread
Results 1 to 9 of 9

Freeze Panes code not working

  1. #1
    Registered User
    Join Date
    09-28-2012
    Location
    Corsham, Wilts
    MS-Off Ver
    Excel 2003/2007
    Posts
    4

    Freeze Panes code not working

    I am writing a large amount of data from an Access database to a spreadsheet.

    I have an area of formatting within the code which sets various Ranges and then I Merge columns, set Interior colours, set Borders, and set Column Widths.

    Initially I tried to do this use 'With Selectuion ... End With' but found that the output Merging was very random. So I use this at the top of my formatting code (all objects are dimensioned)

    Please Login or Register  to view this content.
    Then I do the following:

    Please Login or Register  to view this content.
    Then the problem code:

    Please Login or Register  to view this content.
    This just doesn't work properly. The pane freezes on Column E.

    I changed the range to G1, H1, A1, B1 etc. and it sys on Coloumn E.

    I remmed out the 'ObjSht.Range("F1").Select' line and it made no difference.

    I remmed out the 'ObjEXL.ActiveWindow.FreezePanes' line and it didn't freeze the pane (expected).

    I've tried omitting 'ObjEXL' and the result is the same.

    I'm hours into this and cannot resolve it. Can anybody help please?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Freeze Panes code not working

    Set the freeze panes before you merge the cells.

    Also your range and columns properties should reference the sheet object range than the application object.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-28-2012
    Location
    Corsham, Wilts
    MS-Off Ver
    Excel 2003/2007
    Posts
    4

    Re: Freeze Panes code not working

    Andy

    Many thanks. Moving the Freeze Frams code above the Merge Code worked.

    Not sure what yopu mean in your second comment - could you give an example of what you mean please.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Freeze Panes code not working

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-28-2012
    Location
    Corsham, Wilts
    MS-Off Ver
    Excel 2003/2007
    Posts
    4

    Re: Freeze Panes code not working

    Thanks Andy

    Does this apply to all places that I use .Range?

    i.e. with .Merge and .Borders etc?

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Freeze Panes code not working

    Yes.

    I'm not sure I understand how your code was working previously.

  7. #7
    Registered User
    Join Date
    09-28-2012
    Location
    Corsham, Wilts
    MS-Off Ver
    Excel 2003/2007
    Posts
    4

    Re: Freeze Panes code not working

    Andy

    No I can't understand it but it did - maybe because I have only one worksheet in play?

    Anyway thanks for all your help - I have now fully created the spreadsheet from a table of data with full cell formatting. That part of the app is finished and I can move on now to putting in more data.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Freeze Panes code not working

    if the sheet is active then objsht.range is the same as objEXL.range so it would work. your syntax is better though :-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Freeze Panes code not working

    You're right JP.

    I must have done something slightly different when building a test case of dtess8's code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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