+ Reply to Thread
Results 1 to 12 of 12

Excel vba userform - lock userform in place

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Excel vba userform - lock userform in place

    I have a userform that has a password protect on the userform. The problem is anyone can drag the userform down and access sheet 3. How to I stop this from happening so only staff with a password can get to sheet 3.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Excel vba userform - lock userform in place

    You could hide Sheet3 like you did with Sheet2 and Sheet1. Then your "password" code Unhides Sheet3 like it already does. You would need a least one sheet visible if Sheet3 is hidden. You could have a blank dummy Sheet4 visible.

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel vba userform - lock userform in place

    I really don't want to hide sheet 3, it's already locked so no one can edit it without a password. Just want the user form to stay in place and not be dragged arround.

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Excel vba userform - lock userform in place

    I am very sorry, I do not remember the author of code but I use it, see if it helps you!
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel vba userform - lock userform in place

    Alot of complie errors, didn't like "Me" anywhere in this code. Maybe it's me and not the code ☺

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Excel vba userform - lock userform in place

    check the file, the code I added (you can see the '**** ... and delete the button from yr sheet, is just for testing
    Attached Files Attached Files
    Last edited by john55; 04-30-2013 at 09:20 AM.

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel vba userform - lock userform in place

    the code has to be in the userform not a normal module-or you'll get Me errors
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  8. #8
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel vba userform - lock userform in place

    Made those adjustments but now when I debug, I get Compile error at "q =" variable not defined. Never had this error before.

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Excel vba userform - lock userform in place

    check all and see where you added by mistake a q

  10. #10
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel vba userform - lock userform in place

    This "q" is where I am getting hung up....... It never had an error here before I included your code.

    With ThisWorkbook.Worksheets("Sheet3")
    → q = .Cells(.Rows.Count, "a").End(xlUp).Row + 1
    .Cells(q, 1).Value = Me.txtMaterial.Value
    .Cells(q, 2).Value = Me.txtBin.Value
    .Cells(q, 3).Value = Me.txtIssued.Value
    .Cells(q, 4).Value = Me.txtReceived.Value
    .Cells(q, 5).Value = Me.txtDate.Value
    .Cells(q, 6).Value = Me.cboDEPARTMENT.Value
    .Cells(q, 7).Value = Me.txtRecipient.Value
    .Cells(q, 8).Value = Me.txtFaics.Value
    .Cells(q, 9).Value = Me.cboInitials.Value

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel vba userform - lock userform in place

    you need to declare q
    Please Login or Register  to view this content.
    before you use it

  12. #12
    Registered User
    Join Date
    04-03-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Excel vba userform - lock userform in place

    Everything is working GREAT!

+ 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.6.0 RC 1