![]() |
Workbook_Open() Not working
The following code works well if run manually but not when the file is open.
What can I do to remedy this? Thanks. Private Sub Workbook_Open() ActiveSheet.Unprotect ' Unprotect the active sheet ' Sort the list by the first field when the workbook is opened. Range("JobList").Sort Key1:=Range("headers").Columns, _ Order1:=xlAscending, Header:=xlYes ' Select next available row in the second column. Cells(Range("JobList").Rows.Count, Range("JobList").Column + 1).Select Selection.End(xlUp).Offset(1).Select ' Protect the active sheet without a password ActiveSheet.Protect DrawingObjects:=False, _ Contents:=True, Scenarios:=False End Sub |
Workbook_Open() Not working
Open the VBA Editor and type this in the VB editor:
?Application.EnableEvents if it returns "False" Then type this: Application.EnableEvents = True Let me know if that doesn't work Charles Dave wrote: The following code works well if run manually but not when the file is open. What can I do to remedy this? Thanks. Private Sub Workbook_Open() ActiveSheet.Unprotect ' Unprotect the active sheet ' Sort the list by the first field when the workbook is opened. Range("JobList").Sort Key1:=Range("headers").Columns, _ Order1:=xlAscending, Header:=xlYes ' Select next available row in the second column. Cells(Range("JobList").Rows.Count, Range("JobList").Column + 1).Select Selection.End(xlUp).Offset(1).Select ' Protect the active sheet without a password ActiveSheet.Protect DrawingObjects:=False, _ Contents:=True, Scenarios:=False End Sub |
Workbook_Open() Not working
I'm not sure how this is suppose to work.
When I entered ?Application.EnableEvents It was immediately changed to Print Application.EnableEvents No True or False. However, I did discover that by placing the code in "ThisWorkbook" it worked just right. "Die_Another_Day" wrote: Open the VBA Editor and type this in the VB editor: ?Application.EnableEvents if it returns "False" Then type this: Application.EnableEvents = True Let me know if that doesn't work Charles Dave wrote: The following code works well if run manually but not when the file is open. What can I do to remedy this? Thanks. Private Sub Workbook_Open() ActiveSheet.Unprotect ' Unprotect the active sheet ' Sort the list by the first field when the workbook is opened. Range("JobList").Sort Key1:=Range("headers").Columns, _ Order1:=xlAscending, Header:=xlYes ' Select next available row in the second column. Cells(Range("JobList").Rows.Count, Range("JobList").Column + 1).Select Selection.End(xlUp).Offset(1).Select ' Protect the active sheet without a password ActiveSheet.Protect DrawingObjects:=False, _ Contents:=True, Scenarios:=False End Sub |
Workbook_Open() Not working
On Wed, 6 Sep 2006, Dave wrote:
The following code works well if run manually but not when the file is open. What can I do to remedy this? Thanks. Private Sub Workbook_Open() ActiveSheet.Unprotect ' Unprotect the active sheet ' Sort the list by the first field when the workbook is opened. Range("JobList").Sort Key1:=Range("headers").Columns, _ Order1:=xlAscending, Header:=xlYes ' Select next available row in the second column. Cells(Range("JobList").Rows.Count, Range("JobList").Column + 1).Select Selection.End(xlUp).Offset(1).Select ' Protect the active sheet without a password ActiveSheet.Protect DrawingObjects:=False, _ Contents:=True, Scenarios:=False End Sub Dave, What is it doing? Is it running but erroring out, or not running at all? MP- |
Workbook_Open() Not working
Press Ctrl+G to bring up the Immediate window, then type that in there.
And yes the Workbook_Open() Sub Must be in the "ThisWorkbook" Module in order to work. Charles Dave wrote: I'm not sure how this is suppose to work. When I entered ?Application.EnableEvents It was immediately changed to Print Application.EnableEvents No True or False. However, I did discover that by placing the code in "ThisWorkbook" it worked just right. "Die_Another_Day" wrote: Open the VBA Editor and type this in the VB editor: ?Application.EnableEvents if it returns "False" Then type this: Application.EnableEvents = True Let me know if that doesn't work Charles Dave wrote: The following code works well if run manually but not when the file is open. What can I do to remedy this? Thanks. Private Sub Workbook_Open() ActiveSheet.Unprotect ' Unprotect the active sheet ' Sort the list by the first field when the workbook is opened. Range("JobList").Sort Key1:=Range("headers").Columns, _ Order1:=xlAscending, Header:=xlYes ' Select next available row in the second column. Cells(Range("JobList").Rows.Count, Range("JobList").Column + 1).Select Selection.End(xlUp).Offset(1).Select ' Protect the active sheet without a password ActiveSheet.Protect DrawingObjects:=False, _ Contents:=True, Scenarios:=False End Sub |
All times are GMT +1. The time now is 02:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com