Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Before_Save event

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Jefferson City, Missouri
    Posts
    382
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Here's my code in the before_save event of the workbook.

    If ActiveWorksheet = Sheets("Sheet5") Then
    Sheets("Sheet1").Activate
    else
    Exit Sub
    End if

    I previously had only the second line and it worked great but do to user complaints of the workbook activating sheet 1 before it saved I need to change it so that it will only activate sheet 1 before it saves if the active sheet at the time of save is sheet 5.

    I am getting an error on the first line of the above code. What's wrong?

    thanks,

    I appreciate the help from everyone at Mr. Excel.

    viper

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    Greenwood, SC
    Posts
    677
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Can't explain exatly why, but this code works:

    If ActiveSheet.Name = "Sheet5" Then
    Sheets("Sheet1").Activate
    Else
    Exit Sub
    End If

    I would guess that ActiveWorksheet and the Sheets objects are not directly comparable.

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't think there is an activeworksheet object...

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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