stevieinselby
New Member
- Joined
- Nov 12, 2015
- Messages
- 27
I have a shared workbook with frozen frames and autofilters. You know what's coming next ... yes, other people frequently leave filters set, and that messes things up when the next person comes along, takes the filters off, and now the first umpteen rows are frozen and they can't scroll. So I have put code into Workbook_Open that unfilters the page and resets the frozen frames ... all working fine. I also want to set one particular filter, and after about 100 attempts I have managed to get that working ... but only when the workbook is not shared. As soon as I share the workbook, I get the dreaded Run-time error '1004': Application-defined or object-defined error. And now because the workbook is shared, I can't even debug it to find where the error is. The worksheet is protected, I don't know if that makes a difference.
If I put On Error Resume Next then it does everything in Workbook_Open except applying the filter Field8="M"
Any suggestions as to how to make it work? Or am I trying to achieve something that Excel makes impossible?
Code:
With Sheets("Sheet1")
.Activate
ActiveSheet.AutoFilter.ShowAllData
ActiveWindow.FreezePanes = False
ActiveWindow.SplitColumn = 3
ActiveWindow.SplitRow = 1
ActiveWindow.FreezePanes = True
.Range("C1:BC1").AutoFilter
.Range("C1:BC1").AutoFilter Field:=8, Criteria1:="M"
End With
If I put On Error Resume Next then it does everything in Workbook_Open except applying the filter Field8="M"
Any suggestions as to how to make it work? Or am I trying to achieve something that Excel makes impossible?