Workbook_open

  • Hi,


    I am having a problem with the following code in a spreadsheet. It doesn't work. I have put it in a different spreadsheet and it works fine. What could be the problem with this spreadsheet?


    Thanks,


    Daniel


    Code
    Private Sub workbook_open()
    Sheet5.Select
    End Sub
  • Re: Workbook_open


    If it works in another spreadsheet.. I have no idea.


    Try:

    Code
    Sheets(5).Select
    Sheet(5).Select
    Sheets5.Select
    Sheets("namehere").Select


    and see if any of them work. There's a link on ozgrid somewhere about the different ways to refer to specific sheets, I looked really fast but didn't find it. I'm sure someone has it bookmarked and will come along and give you the link soon if you can't find it ;)

  • Re: Workbook_open


    Thanks for your help. Sheet 5 does exist. What confuses me is that the exact same code works in another workbook but no in this one. What could affect this spreadsheet that blocks this code from working?


    Daniel

  • Re: Workbook_open


    Quote from DMariotti

    Thanks for your help. Sheet 5 does exist. What confuses me is that the exact same code works in another workbook but no in this one. What could affect this spreadsheet that blocks this code from working?


    Daniel


    I'm just a rookie at this; but, I had a similar problem that I corrected by going to the sheet and going through the renaming process making sure there were no spaces on either end of the sheet name.

  • Re: Workbook_open


    Ken,


    Thanks for you help. My sheet isn't called Sheet 5 as per the workbook tab. I am using the name Sheet5 as allocated by Excel in the VBA project window


    Daniel

  • Re: Workbook_open


    Just to confirm, when you open the workbook you want the worksheet "Valid" to be selected ?


    This works for me when i open it, if it doesnt work for you, im not sure what the problem would be :confused:

  • Re: Workbook_open


    Ok I changed :


    Code
    sheets(5).Select


    to


    Code
    sheets("Menu").Select


    And it worked for me, let me know if it works for you : D


    Code
    sheets(1).Select

    will also do the trick

  • Re: Workbook_open


    Hi,
    Open up VBE and delete your code

    Code
    Private Sub workbook_open() 
        Sheet5.Select 
    End Sub


    Now, still in VBE, select "Workbook" from the Code Window drop-down list. The default should be the Workbook Open event.
    Type "Sheet5.Select"
    Save and open up again.


    This is what I did with your sample file and I got it to work perfectly.

  • Re: Workbook_open


    Code
    Sheets("Sheet5").Select


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!