I have very good Excel skills but very poor VBA.
I have the following code (thanks to this site of course) and need a little more help.
I have remarked out the first few lines as I could not get it to work and added the other lines to filter each sheet in turn.
What I need is to add a password check to the login and get around a user just closing the Form.
I have a sheet called Login Details and a range called Departments which contains the Departments in the first Col and the Password in the next.
Hope thats all clear and thanks again.
Sub FilterToDept()
'For Each sht In ThisWorkbook.Worksheets
'sht.Protect userinterfaceonly:=True
'Range("A9").Select
' sht.Range("A11").AutoFilter field:=1, Criteria1:=CboDept.Text
'Next
Dim oSheet As Object
'Unprotect alll sheets
For Each oSheet In ActiveWorkbook.Sheets
oSheet.Activate
If ActiveSheet.ProtectContents = True Then ActiveSheet.Unprotect ("Louise")
Next
'Apply filter
Worksheets("April").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
Worksheets("Summary 04").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
'Worksheets("May").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
'Worksheets("June").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
FrmLogIn.Hide
' Protect sheets again
For Each oSheet In ActiveWorkbook.Sheets
oSheet.Activate
If ActiveSheet.ProtectContents = False Then ActiveSheet.Protect ("Louise")
Next
' Hide login sheet
Worksheets("LogInDetails").Visible = False
End Sub
Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
I have the following code (thanks to this site of course) and need a little more help.
I have remarked out the first few lines as I could not get it to work and added the other lines to filter each sheet in turn.
What I need is to add a password check to the login and get around a user just closing the Form.
I have a sheet called Login Details and a range called Departments which contains the Departments in the first Col and the Password in the next.
Hope thats all clear and thanks again.
Sub FilterToDept()
'For Each sht In ThisWorkbook.Worksheets
'sht.Protect userinterfaceonly:=True
'Range("A9").Select
' sht.Range("A11").AutoFilter field:=1, Criteria1:=CboDept.Text
'Next
Dim oSheet As Object
'Unprotect alll sheets
For Each oSheet In ActiveWorkbook.Sheets
oSheet.Activate
If ActiveSheet.ProtectContents = True Then ActiveSheet.Unprotect ("Louise")
Next
'Apply filter
Worksheets("April").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
Worksheets("Summary 04").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
'Worksheets("May").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
'Worksheets("June").Range("A1").AutoFilter field:=1, Criteria1:=CboDept.Text
FrmLogIn.Hide
' Protect sheets again
For Each oSheet In ActiveWorkbook.Sheets
oSheet.Activate
If ActiveSheet.ProtectContents = False Then ActiveSheet.Protect ("Louise")
Next
' Hide login sheet
Worksheets("LogInDetails").Visible = False
End Sub
Neil Berryman
IT Trainer
neil_berryman@btopenworld.com