+ Reply to Thread
Results 1 to 25 of 25

Scroll Wheel mouse on a userform frame

  1. #1
    Registered User
    Join Date
    03-02-2015
    Location
    Germany
    MS-Off Ver
    WIN 7
    Posts
    19

    Red face Scroll Wheel mouse on a userform frame

    Hi guys,

    I´m tying to be able to scroll up down with my mouse on a frame inside a userform, but so far I was not able to make it work,

    I´ve searched and I came across this code, which I will paste below, changed the name of the userform, also the name of the frame on the userform module, but it continues not working,

    #it does not give any error, simply does not work.

    This is the example file FormScroll.xls

    and here is the code pasted on the main Module

    Please Login or Register  to view this content.
    and here is the part pasted on the userform module

    Please Login or Register  to view this content.

    I´m using excel 2010 and win 7, 32 bit as shown below

    sys.jpg

    I appreciate your help, because I have no ideia what I´m doing wrong,

    Thanks in Advance

    Regards,

    Laurel

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    Hi Laurel,

    The following UserForm Code made the difference for me using Vista 32 bit and Excel 2003:
    Please Login or Register  to view this content.
    Sample Workbook attached.

    Links of Interest:
    http://www.mrexcel.com/forum/excel-q...lications.html
    https://msdn.microsoft.com/en-us/lib...ice.14%29.aspx

    Lewis
    Last edited by LJMetzger; 03-10-2015 at 04:22 PM. Reason: Removed attachment - would only work in Excel 2003 - see post #10 for attachment.

  3. #3
    Registered User
    Join Date
    03-02-2015
    Location
    Germany
    MS-Off Ver
    WIN 7
    Posts
    19

    Re: Scroll Wheel mouse on a userform frame

    Hi Lewis,

    thanks for the reply,

    unfortunately does not work in my system,

    I will continue looking,

    Thank you anyway

    Laurel

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    Entire post deleted by LJMetzger. See post #10 in this thread for files that work.

    Lewis
    Last edited by LJMetzger; 03-10-2015 at 04:21 PM. Reason: Attachment did not work. Deleted post with reference to good post.

  5. #5
    Registered User
    Join Date
    03-02-2015
    Location
    Germany
    MS-Off Ver
    WIN 7
    Posts
    19

    Re: Scroll Wheel mouse on a userform frame

    Hi Lewis,

    Thank you very much for that, but continues not to working, not sure if is my system, but simply does not work on Win 7, Excel 2010,

    I´m searching and searching, but so far with no results,

    Thanks for the reply,

    Laurel

  6. #6
    Registered User
    Join Date
    08-07-2004
    Location
    Colorado
    MS-Off Ver
    365
    Posts
    62

    Re: Scroll Wheel mouse on a userform frame

    On investigation, on initial opening of workbook and selecting user form, nothing happens. After again selecting worksheet then user form again the scroll works - but very slow.

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    Thanks for the feedback itsunclebill.

    On investigation, on initial opening of workbook and selecting user form, nothing happens. After again selecting worksheet then user form again the scroll works...
    Interesting that you should say that. It works flawlessly for me in Excel 2003 (Vista 32 bit) and in 32 bit Excel 2010 (Windows 8.1 64 bit) when I replace the 'Dim' with 'Private' as in post #4 above . However when I put the 'Dim' back in, I see similar symptoms. If I insert the 'Debug.Assert False' (in red below), it works with the 'Dim' statement.

    Please Login or Register  to view this content.
    ----------------
    ... the scroll works - but very slow.

    That is probably because the following lines move up/down one increment at a time. If the up/down lines were repeated (several times), you would probably get the appearance of more robust functionality.
    Please Login or Register  to view this content.
    Lewis

  8. #8
    Registered User
    Join Date
    03-02-2015
    Location
    Germany
    MS-Off Ver
    WIN 7
    Posts
    19

    Re: Scroll Wheel mouse on a userform frame

    Dear both,

    Thank you,

    itsunclebill I haven´t tried that, but is true, after selecting the worksheet and then select the form it starts to work, and by any reason the wheel mouse works in a reversed away.

    Lewis I change the code as in mentioned, but it always stops on the line
    Please Login or Register  to view this content.
    , then I press run again and it works fine without having to select first the worksheet

    How can I change the code in order to have the userform working when it opens without having to select the worksheet and then go back to the form?

    Thank you for your support,

    Laurel

    My question is how to

  9. #9
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    Hi Laurel,

    The 'Debug.Assert False line is supposed to make it stop. Comment out the line or delete it.

    If the wheel mouse works in a reverse way, change the following code in Sub MouseWheel() in the UserForm module:
    Please Login or Register  to view this content.
    Lewis

  10. #10
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    With a lot of assistance, I was successful in getting MouseScroll to work on both a Modal and Non-Modal UserForm. Attached are two files using slightly different approaches. Both files worked for me on a
    1. Vista 32 bit System using Excel 2003.
    2. Windows 8.1 System using 32 bit Excel 2010.

    a. ExcelForumUserformListBoxMouseScroll-2015-03-10-11-25.xlsm is courtesy of RomperStomper based on original code by Peter Thornton. Thank you both. This file uses a UserForm ListBox.
    https://social.msdn.microsoft.com/Fo...0?forum=isvvba

    b. ExcelForumUserFormMouseWheel3-2015-03-10-11-53.xls is based on a file courtesy of a French Excel Forum. Thank you BrunoM45. The original file was found at: http://www.excel-downloads.com/forum...ml#post1140294
    This file has 3 different UserForms:
    UserForm1 - Mouse Scroll in a Frame.
    UserForm2 - Mouse Scroll in a UserForm.
    Userform3 - Mouse Scroll in a UserForm, a Frame, a ComboBox, and 2 ListBoxes.

    Lewis

  11. #11
    Registered User
    Join Date
    03-02-2015
    Location
    Germany
    MS-Off Ver
    WIN 7
    Posts
    19

    Re: Scroll Wheel mouse on a userform frame

    Hi Lewis,

    you made me very happy today

    I´m grateful for your help, I was almost giving up on this.

    Thank you very much for you patience and effort,

    Regards,

    Laurel

  12. #12
    Registered User
    Join Date
    06-18-2015
    Location
    Poland
    MS-Off Ver
    2013 64-bit
    Posts
    2

    Re: Scroll Wheel mouse on a userform frame

    ExcelForumUserformListBoxMouseScroll-2015-03-10-11-25.xlsm‎

    Thanks for this code, because when I made simple changes it works on 64-bit machine.


    Please Login or Register  to view this content.
    Last edited by kilerus; 06-18-2015 at 05:34 PM.

  13. #13
    Registered User
    Join Date
    06-18-2015
    Location
    Poland
    MS-Off Ver
    2013 64-bit
    Posts
    2

    Re: Scroll Wheel mouse on a userform frame

    Hi again,

    I rebuilt this code to make it simply to use in UserForms. Unfortunatelly the Excel crashes when I use mouse wheel in my large classes. I have class to make table in UserForm (I use only standard controls, TreeView case taught me a lot ).

    Why is this happening? There is any posibility to fix it?

    ExcelForumUserformListBoxMouseScroll-2015-06-22.xlsm

  14. #14
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Scroll Wheel mouse on a userform frame

    Thanks for the additional info, but the result stays the same with my touchpad.

  15. #15
    Registered User
    Join Date
    05-06-2016
    Location
    Turin
    MS-Off Ver
    2010
    Posts
    1

    Re: Scroll Wheel mouse on a userform frame

    Hello, thank you, this discussion solved my problems too, I have been in trouble for 2 weeks before!
    Only one remark. I have a form that dinamically creates comboboxes during form execution. if (and only if) I scrolled my userform with mousewheel, when closing the form all the comboboxes are cleared and this clears also the cells referred by comboboxes via Rowsource property. I bypassed the problem by adding, at the beginning of Userform_terminate sub the following lines:

    For i = 1 To nobjects
    ecubox(i).ControlSource = ""
    combox(i).ControlSource = ""
    Next i

    In this way controlsource links are deleted before they can make damage to the sheet.
    Ciao!
    Last edited by francescoRome; 05-10-2016 at 03:20 AM. Reason: added important remark

  16. #16
    Registered User
    Join Date
    09-06-2012
    Location
    Vanuatu
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Scroll Wheel mouse on a userform frame

    Hello, Has anyone managed to get 'ListBox MouseWheel Scrolling' working properly on 64Bit/VBA7?
    I'm using Excel 2016 and have tried adapting the code using PtrSafe and LongPtr but I just can't make it work.
    If anyone has a working sample, I would really appreciate a copy.
    Thanks

  17. #17
    Registered User
    Join Date
    09-06-2012
    Location
    Vanuatu
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Scroll Wheel mouse on a userform frame

    Update:
    After many hours of playing with the code in Post#10 for UserformListBoxMouseScroll
    I've managed to get it working in 32Bit and 64Bit/VB7
    The odd thing is, it works even though I had to remove the following line from the HookListBoxScroll Sub:
    Please Login or Register  to view this content.
    As when compiling in 64 Bit, it gave a 'Type Mismatch' for GetWindowLongPtr
    If I removed the 'Ptr' it would give 'Sub or Function not defined'
    No matter how many different ways I modified the 'Declare Function' for 'GetWindowLong' I couldn't fix this.
    I'm not really sure what this line does but it seems to work ok without it.
    Does anyone know if removing this line is going to cause any problems that I haven't discovered yet?
    Anyway, here is the working code:
    Please Login or Register  to view this content.
    Last edited by Bip; 05-18-2016 at 06:55 AM.

  18. #18
    Registered User
    Join Date
    08-09-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    3

    Re: Scroll Wheel mouse on a userform frame

    Hello,

    Do you have a code that will work for 64 bit OS. Thank you in advance.

    Jorge

  19. #19
    Registered User
    Join Date
    09-06-2012
    Location
    Vanuatu
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Scroll Wheel mouse on a userform frame

    Jorge, It should work in 64 bit.

  20. #20
    Registered User
    Join Date
    08-09-2016
    Location
    Philippines
    MS-Off Ver
    MS Office 2013
    Posts
    3

    Re: Scroll Wheel mouse on a userform frame

    Hi, what I mean was the code to scroll a frame in userform. Scrolling listbox works fine in my PC. I just made some changes in the code and it worked. I tried playing with the code in post #10 (ExcelForumUserFormMouseWheel3-2015-03-10-11-53) but it didn't work. Can you give me the code to scroll a frame that works in PC with 64 bit OS? Thank you in advance.

    Jorge

  21. #21
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Scroll Wheel mouse on a userform frame

    hurhey welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  22. #22
    Registered User
    Join Date
    07-14-2016
    Location
    Ohio
    MS-Off Ver
    2016
    Posts
    5

    Re: Scroll Wheel mouse on a userform frame

    Removed post - does not comply with rules, sorry. I'll start a new thread.
    Last edited by dan0291; 10-12-2016 at 08:51 PM.

  23. #23
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Scroll Wheel mouse on a userform frame

    See the attached file which is an upgrade (32 Bit Excel only) of the file in post #10 above. The only change is the ability to process the Mouse Wheel on MultiPage controls.

    The following code is in the UserForm4 code module:
    Please Login or Register  to view this content.
    The code in red was added to the MouseWheel processing routine in an ordinary code module:
    Please Login or Register  to view this content.
    Lewis

  24. #24
    Registered User
    Join Date
    11-10-2016
    Location
    Little Rock, AR
    MS-Off Ver
    2010
    Posts
    1

    Re: Scroll Wheel mouse on a userform frame

    Thank you! This workbook is the only one that I've found, after many hours of looking for UserForm mouse scrolling, that actually worked for me.

    It even works in CATIA V5 for me in a .catvba
    Last edited by praterw; 11-10-2016 at 01:06 PM.

  25. #25
    Registered User
    Join Date
    03-11-2016
    Location
    Montreal
    MS-Off Ver
    2010
    Posts
    2

    Re: Scroll Wheel mouse on a userform frame

    LongPtr was the key thank you my hero

+ 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. Scroll horizontally with a mouse wheel
    By luv2glyd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2010, 11:16 AM
  2. Scroll with mouse wheel on userform
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2007, 08:19 PM
  3. [SOLVED] scroll with wheel mouse
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2005, 04:05 PM
  4. User Form - frame scroll with wheel mouse and cut & paste from tex
    By Kenjaro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2005, 11:06 PM
  5. MAKE WHEEL MOUSE WORK ON USER FORM FRAME WITH SCROLL BAR HELP!!!!!
    By Kenjaro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2005, 11: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