+ Reply to Thread
Results 1 to 7 of 7

Userform Scrollbar Event

  1. #1
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Userform Scrollbar Event

    I got a little problem with searching for the correct event or the result of it.

    I want to have an event that will activate a script when the value of a scrollbar changes. (not other property changes)

    I know i need this event:
    Please Login or Register  to view this content.
    but how do i make it so that it only triggers the script when the value of the scroll bar is changed

    (scrollbar is scrolled down or up to change value)
    Tnxs in advance
    Last edited by vin1; 03-30-2011 at 03:47 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Userform Scrollbar Event

    I don't follow you - the change event will only fire when the scrollbar value changes.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Userform Scrollbar Event

    As RS says the change event will only fire when the scroll value changes.

    Changes are triggered by clicking either End Arrow or within the scrollbar (large change).

    Dragging the scroll button, located within the scroller, will trigger the Scroll event and upon release of the button the change event will fire.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Userform Scrollbar Event

    I tought so too, But when i change the minimum and maximum of the scroll bar at initialize it fires the scrollbar_change.

    Also turning off the events within the Userform_Initialize does not work


    this is my code within the Userform_Initialize
    Please Login or Register  to view this content.
    in both cases it drops to the Scrollbar_change while events should be off.

    In this case i fixed it with a little if function. but .EnableEvents False/ True to work for this.
    or to make sure the scrollbar_change only fires the script if the value is changed 1 up or 1 down from last value.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: Userform Scrollbar Event

    For me the event only fires if the min is greater than value, which on initialize is zero.

    EnableEvents will not affect the userform. You will need to use a variable, local to the userform, so you know when to remain in the change event.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Userform Scrollbar Event

    That should only trigger a change event if altering the min and/or max requires a change in value - e.g. you set the min to 1, but the value is 0 at design time (so when you set the min, the value has to change to 1).
    Enableevents does not affect controls - you need to use a boolean flag variable declared at the top of the module.

  7. #7
    Forum Contributor
    Join Date
    02-07-2011
    Location
    netherlands
    MS-Off Ver
    Excel 2003
    Posts
    128

    Re: Userform Scrollbar Event

    It (almsot) works now.

    i just got 1 issue

    Please Login or Register  to view this content.
    Could you explain what this does?
    Also i recieve an error from it from the macro that is placed above this line.


    Please Login or Register  to view this content.


    #Edit

    you need to use a boolean flag variable declared at the top of the module
    Sorry answer was given.

    Solved Tnxs alot
    Last edited by vin1; 03-30-2011 at 03:47 AM.

+ 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