Hello,
I'm trying to allow users to both filter and sort protected sheets with VBA.
The code I currently have is working for the filtering part of it but the sorting does not.
This is my full code for that section, the protect part of it is on the bottom:
I'm trying to allow users to both filter and sort protected sheets with VBA.
The code I currently have is working for the filtering part of it but the sorting does not.
This is my full code for that section, the protect part of it is on the bottom:
VBA Code:
Private Sub SubmitButton_Click()
'Sheets("IDN").Activate THIS LINE MESSES UP THE VALUE FOR THE ACCOUNT LABEL IN THE USERFORM DON'T USE
Sheets("RDs").Cells(1, 4) = Me.RdComboBox.Value
Sheets("RDs").Cells(2, 4) = ""
'FILTER ALL TABLES'
Dim IDNLastRow As Long
Dim BTLastRow As Long
Dim NPILastRow As Long
Dim ENDLastRow As Long
Dim RDName As String
RDName = Me.RdComboBox.Value
'FIND LASTROW AND FILTER
IDNLastRow = Sheets("IDN").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("IDN").Range("A2" & ":S" & IDNLastRow).AutoFilter Field:=1, _
Criteria1:=RDName
BTLastRow = Sheets("BT").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("BT").Range("A2" & ":T" & BTLastRow).AutoFilter Field:=1, _
Criteria1:=RDName
NPILastRow = Sheets("NPI").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("NPI").Range("A2" & ":T" & NPILastRow).AutoFilter Field:=1, _
Criteria1:=RDName
ENDLastRow = Sheets("END").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("END").Range("A2" & ":T" & ENDLastRow).AutoFilter Field:=1, _
Criteria1:=RDName
'Protect Sheets
Sheets("IDN").Protect , AllowFiltering:=True, AllowSorting:=True
Sheets("BT").Protect , AllowFiltering:=True, AllowSorting:=True
Sheets("NPI").Protect , AllowFiltering:=True, AllowSorting:=True
Sheets("END").Protect , AllowFiltering:=True, AllowSorting:=True
Unload Me
End Sub