+ Reply to Thread
Results 1 to 17 of 17

Can seem to get Excel to go to open to a specific worksheet.

  1. #1
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Can seem to get Excel to go to open to a specific worksheet.

    I am having trouble getting Excel to open to a specific worksheet.

    I am using

    Sub Workbook_Open()
    ActiveWorkbook.Worksheets("ControlLoops").Activate
    MsgBox ("Test")
    End Sub

    This was insufficient as Excel ends up on a different sheet (possibly the last work sheet I created) that wasn't the worksheet I save the workbook with.

    When I added,

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    MsgBox ("Test2")
    End Sub

    It seems that I end up on the correct worksheet. Removing the MsgBox inside _SheetActivate causes the wrong worksheet to be opened.

    Ian

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can seem to get Excel to go to open to a specific worksheet.

    I suspect you have created a module level Workbook_Open procedure.

    You should be using the Workboook level

    Private Sub Workbook_Open()

    procedure.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Hmm. I only have one workbook_open () subroutine defined in the ThisWorkbook.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Quote Originally Posted by ijourneaux View Post
    Hmm. I only have one workbook_open () subroutine defined in the ThisWorkbook.
    Can I suggest you upload the workbook so that we can see the behaviour in context.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Does this work?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    I spent most of yesterday Trying to track down what was causing the strange behavior but not luck.

    Darn. The size is too large. I am also using a specialized control so I am not sure if you could run it if I could upload it.

    I did a search for activate in my code and can't seem to find anything that would make it go to the worksheet in question and override my direct call to activate the worksheet I want.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Quote Originally Posted by ijourneaux View Post
    I spent most of yesterday Trying to track down what was causing the strange behavior but not luck.

    Darn. The size is too large. I am also using a specialized control so I am not sure if you could run it if I could upload it.
    Delete most of the stuff, in fact since the problem is associated with the Open event delete the lot, an empty workbook (with sheets obviously) will do just as well.

  8. #8
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    I deleted the component and the worksheet now opens on the correct sheet. I thought at first that it was the component that was causing the issue but no such luck. THe problem seems to be more random than that.

    Let me run somemore test to come upw ith a version that is uploadable and demonstrates the problem.

  9. #9
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    I deleted the component and the worksheet now opens on the correct sheet. I thought at first that it was the component that was causing the issue but no such luck. THe problem seems to be more random than that.

    Let me run somemore test to come upw ith a version that is uploadable and demonstrates the problem.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Did you try the code I posted?

  11. #11
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    I consider myself to be pretty proficient with Excel but this one is really odd.

    Whether the worksheet I want is opened or not when I open the workbook is kind of random. When I read Norie's comment it was working as I wanted it to. I made a sime change
    from

    Please Login or Register  to view this content.
    To Norie's recommendation

    Please Login or Register  to view this content.
    what worked (abit briefly) no longer works.

    Alittle more testing incdicates that the msgbox must be there for the Workbook to open the correct worksheet. If it is not there, the worksheet alwasys opens the wrong worksheet (always the same wrong worksheet).
    Last edited by ijourneaux; 06-01-2015 at 04:57 PM.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Is there any other code in the workbook?

    Also, what is this 'component' you mention?

    Is it an add-in? A third-party control? Something else?

    PS Can you add code tags when posting code?

  13. #13
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    There is quite a bit of code but I have search though the code to wits end to see if I could find anything that would unintentionally active the wrong window.

    In one of my worksheets, the last one I added, I have a control installed that display data from a process historian (AspenTech IP.21). This is also the worksheet that is incorrectly activated when I open up the workbook.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can seem to get Excel to go to open to a specific worksheet.

    Is AspenTech IP.21 an add-in?

  15. #15
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    It is an OCX control that I am using to display data from the process historian.

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can seem to get Excel to go to open to a specific worksheet.

    So there's no add-ins?

  17. #17
    Registered User
    Join Date
    06-11-2011
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Can seem to get Excel to go to open to a specific worksheet.

    It seems that one of the controls I am using is causing Excel to change to the wrong worksheet. Is it possible to determine which event are getting fired when and excel workbook is loaded? That way I might be able to track down that is cuaseing the active worksheet to change. I ahve search through all of my code using the name of the worksheet and I don't have any calls to activate that spreadsheet.
    Ian

+ 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. Excel to open specific worksheet
    By hkbhansali in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-24-2014, 01:04 PM
  2. Open Specific Worksheet
    By cargor in forum Excel General
    Replies: 4
    Last Post: 07-12-2006, 01:10 PM
  3. Default a specific worksheet to be in forefront when open excel?
    By jbankert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-01-2006, 11:20 AM
  4. [SOLVED] Open a specific worksheet
    By don in forum Excel General
    Replies: 2
    Last Post: 11-25-2005, 08:15 AM
  5. Replies: 1
    Last Post: 08-26-2005, 05:05 PM

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