+ Reply to Thread
Results 1 to 7 of 7

Set scrollbars to a default starting position when a userform is initialized

  1. #1
    Registered User
    Join Date
    07-07-2014
    Location
    Cat Square
    MS-Off Ver
    365 home 2013
    Posts
    15

    Exclamation Set scrollbars to a default starting position when a userform is initialized

    Hi all,

    I am only a few months into VBA and I am trying to incorporate my first multipage control in a userform. I have both vertical and horizontal scrollbars and have gotten them to scroll properly by setting the scroll height and scroll width properties in the property window. My issue now is getting them to start at the zero position (ScrollTop & Scroll Left) when the userform is initialized. I have written a procedure under the userform set to run when it initializes to set both properties to zero but that didn't work. (Me.ScrollTop = 0 Me.ScrollLeft = 0). Each time I initialized the userform the scrollbars started in the position they were left in the last time the userform was initialized.

    How can I start both scrollbars at the zero position when the userform is initialized?

    Thanks in advance!!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,305

    Re: Set scrollbars to a default starting position when a userform is initialized

    Hi Big_E and welcome to the forum,

    This sounds like you need to Unload the userform instead of close or hide. Read
    http://support.microsoft.com/kb/213744
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    07-07-2014
    Location
    Cat Square
    MS-Off Ver
    365 home 2013
    Posts
    15

    Re: Set scrollbars to a default starting position when a userform is initialized

    Ahhhh.....silly me!! I didn't think about that. I will try that. Thank you very much!

  4. #4
    Registered User
    Join Date
    07-07-2014
    Location
    Cat Square
    MS-Off Ver
    365 home 2013
    Posts
    15

    Re: Set scrollbars to a default starting position when a userform is initialized

    MarvinP,

    I tried your suggestion but that didn't resolve my issue. I created a command button in my form and assigned a macro to unload the form which took me to the active tab in my workbook. On that spreadsheet I inserted a button and assigned a macro to show the userform. As in my initial post I wrote code under the userform to set the positions when the userform is initialized. I clicked the button in my spreadsheet to show the userform, which it did. Then moved the scrollbars and clicked the button in the form to unload the form, which it did. When I clicked the button in my spreadsheet to show the form the scrollbars were where I left them. What did I do wrong? What am I missing?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set scrollbars to a default starting position when a userform is initialized

    You could explicitly set the .ScrollTop and .ScrollLeft properties of the MultiPage's Pages in the Intialize event.

    Your Me.ScrollTop sets the user form's .ScrollTop property. Each Page has its own .ScrollTop property.

    Througout a userform's code module, the Me keyword refers to the Userform.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    07-07-2014
    Location
    Cat Square
    MS-Off Ver
    365 home 2013
    Posts
    15

    Re: Set scrollbars to a default starting position when a userform is initialized

    Hi Mike,

    Thanks for your response. Like I said earlier I am still fairly new to VBA. How do I do that?

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Set scrollbars to a default starting position when a userform is initialized

    I would do something like this. This code assumes there is MultiPage1, myVerticalScrollBar and myHorizontalScrollBar. It accommodates lots of control on various pages in various locations.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Userform code and starting position
    By baltic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2014, 07:38 PM
  2. Checking a userForm that has not been initialized
    By Arne Hegefors in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-02-2006, 09:50 AM
  3. [SOLVED] How does Userform get initialized by this?
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2005, 01:50 PM
  4. Scrollbars starting at the bottom of form
    By cparsons in forum Excel General
    Replies: 0
    Last Post: 07-30-2005, 08:54 PM
  5. [SOLVED] Userform runs other subs when initialized
    By zipdog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2005, 12:06 PM

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