Martin_H
Board Regular
- Joined
- Aug 26, 2020
- Messages
- 190
- Office Version
- 365
- Platform
- Windows
Hi all,
whit this code I would like to open another Excel Worbook (which is locked and shared) if not already opened and apply the filter on Worksheet named "1" to the cell A1 (cell A1 is a header, but it is not a table just a range). So basically after filter is done I want to see only numbers 2, if there are any, under the cell A1.
Code works ok, it opens the Workbook I want but will not filter anything meanwhile filtering on that Shared/Locked Workbook is allowed. I have locked it before with the code below (manual filtering on that Shared/Locked Workbook is working).
Please help me with this one.
Thank you!
whit this code I would like to open another Excel Worbook (which is locked and shared) if not already opened and apply the filter on Worksheet named "1" to the cell A1 (cell A1 is a header, but it is not a table just a range). So basically after filter is done I want to see only numbers 2, if there are any, under the cell A1.
Excel Formula:
Sub ApplyFilter()
On Error Resume Next: Err.Clear: Dim wb As Workbook
Set wb = Workbooks("New Microsoft Excel Worksheet.xlsm"): wb.Activate
If Err.Number > 0 Then Set wb = Workbooks.Open(Filename:="C:\Users\DLBV9NJ\Desktop\New Microsoft Excel Worksheet.xlsm", ReadOnly:=False)
If Not wb Is Nothing Then wb.Worksheets("1").Activate
Sheets("1").Visible = True
With Worksheets("1")
.Activate
.Range("A1").AutoFilter field:=1, Criteria1:="2"
End With
End Sub
Code works ok, it opens the Workbook I want but will not filter anything meanwhile filtering on that Shared/Locked Workbook is allowed. I have locked it before with the code below (manual filtering on that Shared/Locked Workbook is working).
Excel Formula:
Sub Protect1()
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, UserInterfaceOnly:=True
End Sub
Please help me with this one.
Thank you!