Consulting

Results 1 to 7 of 7

Thread: Problems freezing the header row form scrolling

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    7
    Location

    Problems freezing the header row form scrolling

    Hello,

    I've created a userForm to connect to an access database to copy data to a Worksheet. This works fine when the data is copied to "Sheet1".
    When the data is copied to "Sheet2" an error is generated. "Select Method of Range class failed.
    [VBA]
    objWorksheet.Rows(2).Select
    objExcel.ActiveWindow.FreezePane = True
    [/VBA]

    Even when the error is generated, the data is still copied to "Sheet2" but the header row scrolls.

    I've attached a doc with the copy data routine only. The error is generated at line 71

    Any help would be much appreciated.

    Thanks

    Karl

  2. #2
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    Make sure the sheet 2 is the active window. If sheet 1 already has frozen pane, it might generate that error.

    Haven't check the file yet, but the first thing to check would be if Sheet2 is in fact the active window.
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    7
    Location
    Hello,

    Thanks for the reply.

    How would I make Sheet2 the active window?

    Regards

    Karl

  4. #4
    VBAX Master XLGibbs's Avatar
    Joined
    Jan 2006
    Location
    state of confusion, but vacation in denial
    Posts
    1,315
    Location
    If the name of Sheet2 is "Sheet2" it would be:

    [VBA]
    Set objWorksheet = Sheets("Sheet2")
    [/VBA]
    If you have posted the same question at multiple forums, please read this IMPORTANT INFO.

    Please use the thread tools to mark your thread Solved


    Please review the Knowledge Base
    for samples and solutions , or to submit your own!




  5. #5
    VBAX Regular
    Joined
    Feb 2007
    Posts
    7
    Location
    Hello,

    Once again thank you for your response. Unfortunately I'm still getting the error.

    Thanks

    Karl

  6. #6
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    [VBA]Worksheets(2).Activate
    Worksheets(2).Rows(2).Select
    ActiveWindow.FreezePanes = True[/VBA]
    Are you doing this in excel ? Because you are creating an instance of excel ... in excel ???

    Charlize

  7. #7
    VBAX Regular
    Joined
    Feb 2007
    Posts
    7
    Location
    Hello Charlise

    Thanks for the tip I was able to get it to work with objWorksheet.Activate

    Regards

    Karl

Posting Permissions

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