+ Reply to Thread
Results 1 to 7 of 7

Thread: Restricting sh.ScrollArea in the Workbook_SheetActivate by windows user login

  1. #1
    Valued Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2007
    Posts
    388

    Restricting sh.ScrollArea in the Workbook_SheetActivate by windows user login

    There are certain things I want my worksheet to be able to do that just do not seem to function very well when I lock it. On the flip side, I need to be able to control who is able to modify what. In the past, that meant locking it, and incorporating password protected "unlock/lock" buttons. This is not practical anymore.

    How can I set a worksheet so that:

    1. User with windows login "abc" can click on and modify anything
    2. User with windows login "def" can click on and modify anything
    3. All other users [wild card?] can only click on macros with specific names "xyz01", "xyz02", etc.
    Last edited by jonvanwyk; 08-18-2011 at 12:15 PM. Reason: clarity

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Instead of locking worksheet; Restrict modification by windows user login

    Review tab - allow users to edit ranges, is as close as you'll get.

    As an aside, Excel is not a secure application and anyone with any nous can break worksheet protection if they want to.

  3. #3
    Valued Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2007
    Posts
    388

    Re: Instead of locking worksheet; Restrict modification by windows user login

    romperstomper: I realize that, but my target audience doesn't even know how to format a cell much less crack a worksheet. Most of the security I need is to prevent users from accidentally screwing things up.

  4. #4
    Valued Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2007
    Posts
    388

    Re: Instead of locking worksheet; Restrict modification by windows user login

    Actually, I just had a thought that might give me exactly what I want. Presently, I am using the following code to restrict the cells that can be clicked on to only those inside of my form (A1:AM50). I noticed that while it prevents the user from selecting a cell in anyway, it does not restrict the use of macros anywhere on the page. Can I make this type of "sch.ScrollArea" user contingent?


    
    
    Private Sub Workbook_SheetActivate(ByVal sh As Object)
    Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
    Application.DisplayFormulaBar = False
    Application.DisplayStatusBar = False
    If IsNumeric(sh.Name) Then
    sh.ScrollArea = "A1:AM50"
    Else
    sh.ScrollArea = "A1:AM50"
    End If
    End Sub


    For instance, can I say:

    If windows user "abc" then allow sh.ScrollArea = "A1:AM50",
    but if any other user, allow sh.ScrollArea = "A1:AM1"

    ??

  5. #5
    Valued Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2007
    Posts
    388

    Re: Restricting sh.ScrollArea in the Workbook_SheetActivate by windows user login

    I have been trying to figure out how to do this independently, but am still at a loss. Does anyone have any suggestions?

  6. #6
    Forum Guru
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    1,798

    Re: Restricting sh.ScrollArea in the Workbook_SheetActivate by windows user login

    This code will base the scroll area on the username. Let me know if it helps.

    Private Sub Workbook_SheetActivate(ByVal sh As Object)
        Dim nm As String
        
        nm = Environ("username")
        
        Select Case nm
            Case "jwv"
                sh.ScrollArea = "A1:B25"
            Case "abc"
                sh.ScrollArea = "A20:b30"
            Case Else
                sh.ScrollArea = "A1:M30"
        End Select
    End Sub

  7. #7
    Valued Forum Contributor jonvanwyk's Avatar
    Join Date
    06-28-2010
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2007
    Posts
    388

    Re: Restricting sh.ScrollArea in the Workbook_SheetActivate by windows user login

    BigBas...your solution works as I needed it to. Thank you for taking the time to answer my question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0