Userform Startup Position - Page 2
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Userform Startup Position

  1. #11
    New Member
    Join Date
    Mar 2017
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Startup Position

     
    Hi there, is it possible to adjust this to have the form position itself based on a cell reference? So maybe the top corner of the form always locates itself in say D9. Apologies if this is an amateurish question...

  2. #12
    New Member
    Join Date
    May 2017
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Startup Position

    This thread might just be the answer to your problem...

    https://www.mrexcel.com/forum/excel-...on-points.html

  3. #13
    New Member
    Join Date
    Mar 2017
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Startup Position

    Many thanks!

  4. #14
    New Member
    Join Date
    Oct 2012
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Startup Position

    Very kewl. I use a lot of dynamic forms. Your code can be used there too. Very kewl!

  5. #15
    New Member
    Join Date
    Apr 2018
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform Startup Position

      
    Quote Originally Posted by JuliusUmulius View Post
    A different approach to this problem is to save the position of the userform when it is closed and load that position once the userform is opened again.
    With this solution the user can position the userform wherever they want, and expect it to appear at that exact position when opened again.
    It solves every problem related to screen sizes, frozen views an do on. One caveat however might be if positioned far right on a big screen, saved and then opened again on a small screen. I haven't tested it, but it could of course be solved with some additional code.


    Code:
    Private Sub UserForm_Activate()    
        Me.Top = [UF_TOP_OFFSET]
        Me.Left = [UF_LEFT_OFFSET]
        
    End Sub
    
    
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        
        If Not [UF_TOP_OFFSET] = Me.Top Or Not [UF_LEFT_OFFSET] = Me.Left Then
    
    
            [UF_TOP_OFFSET] = Me.Top
            [UF_LEFT_OFFSET] = Me.Left
            
        End If
        
    End Sub
    (Variables in brackets "[variable]" point to named ranges, in case you havn't seen this before.)
    I thought that this was a great idea but couldn't get the QueryClose() to work. It gave me "Run-time error '424' Object required" with Excel 2007. I replaced the code with:

    Code:
        If Not [LedgerFormTop] = Me.Top Or Not [LedgerFormLeft] = Me.Left Then
            ActiveWorkbook.Names("LedgerFormLeft").RefersToR1C1 = "=" & Me.Left
            ActiveWorkbook.Names("LedgerFormTop").RefersToR1C1 = "=" & Me.Top
        End If

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com