Consulting

Results 1 to 5 of 5

Thread: Hide rows in excel

  1. #1

    Hide rows in excel

    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.

    [VBA]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[/VBA]

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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Rows.Hidden = False
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Thanks XLD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •