Results 1 to 4 of 4

Thread: VBA Code

  1. #1
    Join Date
    Jul 2005
    Location
    Southampton, UK
    Posts
    7

    Unanswered: VBA Code

    Hi,

    I need what I am sure is a really easy bit of code on an excel workbook.

    I need to ensure that whenever a spreadsheet I have created is opened, it always defaults to a certain worksheet, irrespective of which worksheet it was saved on.

    Hope someone can help

    Cheers
    Paul

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Try this code in the 'ThisWorkbook' module

    Code:
    Private Sub Workbook_Open()
        On Error Resume Next
        Worksheets("YourSheetName").Select
    End Sub
    The On Error code causes errors to be ignored if the sheet name does not exist.

    HTH

    MTB

  3. #3
    Join Date
    Jul 2005
    Location
    Southampton, UK
    Posts
    7
    Thats perfect Mike Cheers

    Paul

  4. #4
    Join Date
    Feb 2006
    Posts
    113
    Some other thoughts.

    You could have some similar code to that offered by Mike but running on file closure. If it is critical, you might also consider if the file is opened without macros enabled. And, in case the worksheet name changes, use the CodeName property.

    regards,
    Fazza

Posting Permissions

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