Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Login and Filter

Status
Not open for further replies.

nberryman

Instructor
Jun 1, 2002
556
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top