Consulting

Results 1 to 8 of 8

Thread: prevent form to make the sheet scroll?

  1. #1
    VBAX Regular
    Joined
    Mar 2013
    Posts
    80
    Location

    prevent form to make the sheet scroll?

    Hello

    I've got a form with property: set to be on the top left corner of the screen. (tried with any setting, same problem)
    I can call it by double click in any cells of the sheet.

    If I am in column AA for example and then double click to call the form, it scroll back to A because of it....
    in other words, is there a way to set a "relative" top left position for the form?

    Thanks

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi.
    setting StartUpPosition property of the UserForm to Windows Default may help.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Mar 2013
    Posts
    80
    Location
    nope, I tried all possible setup for "StartUpPosition", same results.. I also tried with and without values in "Left" and "Top", thinking it was a combinaison of properties, but it changes nothing

  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    startuppostion: 0

    Private Sub UserForm_Initialize()
        Left = ActiveCell.Offset(, 1).Left - ActiveWindow.ActivePane.VisibleRange.Left + 30 * Abs(ActiveWindow.DisplayHeadings)
        Top = ActiveCell.Offset(1).Top + 27 * Abs(Application.DisplayFormulaBar) + 27 * Abs(ActiveWindow.DisplayHeadings) + 27 * Abs(ActiveWindow.DisplayRuler)
    End Sub
    Last edited by snb; 08-11-2014 at 06:33 AM.

  5. #5
    VBAX Regular
    Joined
    Mar 2013
    Posts
    80
    Location
    Thanks snb, I tried, doesn't work. The form take the offset into account (it move a little bit each time) but doesn't prevent the scrolling back to top left.. (if I understand your code, it doesn't recognise VisibleRange as Visible screen)

    As it is not a must but a nice to have, it is OK if you don't have more time to spend on this...

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    I can't see what other code is in your form.

    So the best way is....... to post your sample file.

  7. #7
    VBAX Regular
    Joined
    Mar 2013
    Posts
    80
    Location
    I can't upload anything with my company security high level.. but the good news is that I found the problem... thanks to you, I've checked the rest of the code and found a stupid cells(1,1).select lost in the sheet code..

    So sorry and so happy it works! you're the best...

  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Please, don't mention it to 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
  •