+ Reply to Thread
Results 1 to 7 of 7

Easy Question

Hybrid View

  1. #1
    Registered User
    Join Date
    12-20-2006
    Posts
    28

    Easy Question

    I'm look ing a command to ensure that sample.xls opens on sheet1, no matter what sheet is active when it is closed. Is there also one that ensure sheet2 is clear. Thanks for your help!

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by ScottyNM
    I'm look ing a command to ensure that sample.xls opens on sheet1, no matter what sheet is active when it is closed. Is there also one that ensure sheet2 is clear. Thanks for your help!
    Hi,

    the code
    Option Explicit
    
    Private Sub WorkBook_Open()
        On Error Resume Next
        Sheets("Sheet1").Select
        On Error GoTo 0
    End Sub
    pasted into the ThisWorkBook module will select Sheet1 if it exists.

    For Sheet2 did you want to clear Values or Formula or both?

    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Forum Contributor
    Join Date
    07-05-2006
    Location
    Canada
    MS-Off Ver
    2003, 2007
    Posts
    581
    If you want it totally clear, it would probably be easiest to delete the sheet and put in a new one. If that's the case, we can supply you with code (since I can't remember the specifics off the top of my head).

    Scott

  4. #4
    Registered User
    Join Date
    12-20-2006
    Posts
    28

    Thanks!

    Thanks. What I did, and it seems to work, is wrote the code to when it initially opens it opens to the second sheet(the one that needs to be cleared) and I did a Cell.ClearContents.

    Then I just had it open the first sheet.

    It seems to work. If their is a reason I shouldn't do it this way, let me know.


    Thanks a lot!

  5. #5
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by ScottyNM
    Thanks. What I did, and it seems to work, is wrote the code to when it initially opens it opens to the second sheet(the one that needs to be cleared) and I did a Cell.ClearContents.

    Then I just had it open the first sheet.

    It seems to work. If their is a reason I shouldn't do it this way, let me know.


    Thanks a lot!
    I think the saying is, 'If it works for you . . thats good'.

    just a note on the 'clear', did you put it between the two 'On Error' lines, so that if it failed there was no error shown?

    ---

  6. #6
    Registered User
    Join Date
    12-20-2006
    Posts
    28

    Smile One problem solved then...

    Yes. I did include those lines. Thanks!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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