A
Alex
I'm trying two things that aren't working and it's driving me nuts. I need
my workbook protected when the workbook is opened. For some reason, workbook
protection is a toggle. I'll open it once and it's protected. I'll open it
next time and it's not protected. The other thing I can't get to work is to
turn on autofilter in sheet 'ImportData' each time the workbook opens. Any
ideas what I'm doing wrong? I've tried for hours. . . thanks.
Here's my code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveSheet.AutoFilterMode = False
End Sub
Private Sub Workbook_Open()
On Error Resume Next
AddIns("Analysis ToolPak").Installed = True
AddIns("Analysis ToolPak - VBA").Installed = True
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect password:="mwimport"
Next ws
Worksheets("ImportData").Range("A15000").Locked = True
Worksheets("Trends").Range("A1:BC25").Locked = True
Worksheets("Chart Data").Range("A1:W72").Locked = True
Dim wsh As Worksheet
For Each wsh In ThisWorkbook.Worksheets
wsh.Protect password:="mwimport"
Next wsh
'Hide the OriginalTrends sheet
Sheets("OriginalTrends").Visible = False
Worksheets("ImportData").Unprotect password:="mwimport"
Worksheets("ImportData").Activate
Range("A1").Select
ActiveSheet.AutoFilterMode = True
ActiveWorkbook.Protect password:="mwimport"
End Sub
my workbook protected when the workbook is opened. For some reason, workbook
protection is a toggle. I'll open it once and it's protected. I'll open it
next time and it's not protected. The other thing I can't get to work is to
turn on autofilter in sheet 'ImportData' each time the workbook opens. Any
ideas what I'm doing wrong? I've tried for hours. . . thanks.
Here's my code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveSheet.AutoFilterMode = False
End Sub
Private Sub Workbook_Open()
On Error Resume Next
AddIns("Analysis ToolPak").Installed = True
AddIns("Analysis ToolPak - VBA").Installed = True
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect password:="mwimport"
Next ws
Worksheets("ImportData").Range("A15000").Locked = True
Worksheets("Trends").Range("A1:BC25").Locked = True
Worksheets("Chart Data").Range("A1:W72").Locked = True
Dim wsh As Worksheet
For Each wsh In ThisWorkbook.Worksheets
wsh.Protect password:="mwimport"
Next wsh
'Hide the OriginalTrends sheet
Sheets("OriginalTrends").Visible = False
Worksheets("ImportData").Unprotect password:="mwimport"
Worksheets("ImportData").Activate
Range("A1").Select
ActiveSheet.AutoFilterMode = True
ActiveWorkbook.Protect password:="mwimport"
End Sub