PDA

View Full Version : Hide rows in excel



nbqleebarnes
03-19-2009, 04:40 AM
Hi All,
I have been busy with a login program and I am trying to give certain access to certain users.
I have multiple sheets and I wish to give for example user1 access to rows 1 through 80 and not the rest of the worksheet, and so on for each worksheet.
I have got the code as follows where I need to enter the code for the above mentioned, I would presume that "selected sheet hide range" in code would probably be the answer, but I'm not that good at VB yet.

Private Sub cmdOKBttn_Click()
If txtPassword.Value = "user" Then

frmPWord_AccessLevel.Hide
Sheet1.Select
' I should imagine that the relevant code would be here somewhere?

ElseIf txtPassword.Value = "user1" Then

frmPWord_AccessLevel.Hide
Sheet1.Select

ElseIf txtPassword.Value = "user2" Then

frmPWord_AccessLevel.Hide
Sheet1.Select

ElseIf txtPassword.Value = "user3" Then

frmPWord_AccessLevel.Hide
Sheet1.Select
ElseIf txtPassword.Value = "user4" Then

frmPWord_AccessLevel.Hide
Sheet1.Select

If anyone one could help I would much appreciate it.
Cheers
Lee

Bob Phillips
03-19-2009, 04:42 AM
Private Sub cmdOKBttn_Click()
If txtPassword.Value = "user" Then

frmPWord_AccessLevel.Hide
Sheet1.Select
Rows(81).Resize(Rows.Count - 80).Hidden = True

ElseIf txtPassword.Value = "user1" Then

frmPWord_AccessLevel.Hide
Sheet1.Select

ElseIf txtPassword.Value = "user2" Then

frmPWord_AccessLevel.Hide
Sheet1.Select

ElseIf txtPassword.Value = "user3" Then

frmPWord_AccessLevel.Hide
Sheet1.Select
ElseIf txtPassword.Value = "user4" Then

frmPWord_AccessLevel.Hide
Sheet1.Select
End If
End Sub

nbqleebarnes
03-19-2009, 05:11 AM
Thanks XLD,
I just had to uprotect the sheet first and it works fine, although how do get the rows back if I am a different user.
Cheers
Lee

Bob Phillips
03-19-2009, 05:20 AM
Rows.Hidden = False

nbqleebarnes
03-19-2009, 09:49 PM
Thanks XLD