Locking a userform position

elgringo56

Well-known Member
Joined
Apr 15, 2002
Messages
869
I have a userform that I would like to lock in position. As it is now, if the user "grabs" the top blue bar on the userform, he can move it around, and I would like to prevent that. Is this possible?
 
Interesting, I did a loop count 0 to 6 and it does dim the close button, which is pretty good, I guess. Would like it to be gone altogether, though, if there is a way.
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I know this is an old thread, but here's how I was able to "lock" the userform position, quick and easy.


Code:
Private Sub UserForm_Layout()
    
    If UserForm_Main.Left <> -8 Or UserForm_Main.Top <> 0 Then       'Checks to see if current position matches the presets I defined
        
        MsgBox "Cannot Move Screen.", vbCritical
    
        With UserForm_Main      'Moves userform back to original positions (this eliminates the "duplicate" error for vertical and/or horizontal movement)
            .Left = -8
            .Top = 0
        End With
    
    End If
    
End Sub
 
Upvote 0
Hi All,

I am trying to lock a user form onto a tab "Menu" the code above can i ask where do i put this ? :confused: as i don't seam to be able to get it to work

i have tried on the tab "Menu", on the user form
Can somebody please explain to me please

Can you please put comments in any code - still finding my feet in VBA

Steve
 
Upvote 0

Forum statistics

Threads
1,223,920
Messages
6,175,377
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top