![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
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 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
I don't think there is an activeworksheet object...
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|