Mouse wheel scroll in a combobox on userform (Lots of Code)

Phil_C

New Member
Joined
Aug 25, 2006
Messages
25
Hello All
I have seen some code around that allows scrolling in listboxes using the mousewheel. I have also seen some code here on the forums about scrolling through a combobox embedded in a workbook. I have tried adapting both of these to suit a combobox on a userform but I cannot get either to work.

Here is the code that I used for the embedded combobox; I added it to the base code for the userform

I then added the following code to a standard module as stated in the forum post;

In the first section of the code there is a msgbox that never gets shown so I don't think code is recognizing the mouse wheel at all.

The second set of code that I used was set up to work with a listbox and it works perfectly with a listbox control. The problem is I cannot adapt it to suit a combobox and if I use a breakpoint to see what is happening Excel freezes.
The following code is added to the userforms code;

Then in a standard module I added the following code;

I added this section of the code;


I think this should only work on a Combobox but a Combobox does not appear to support the TopIndex value. Is there a way this can be setup to work with a userform combobox?
Sorry about the huge amount of code.

Thanks in advance

Phil

CODE removed to avoid confusion.
 
Hi Phil,

The reason Excel crashes if there is an error in your code is because the Scroll code uses API calls. You can not debug API calls. Usualy if you were to choose end when your code bugs out and not debug, excel would not crash.

I should have warned you that if you are using API calls you have to be very careful (because you can also really mess up your system with them). My advice to you would be to finnish your code fully (including error traps etc) and then when it is fully functioning and tested add the nice to haves such as this scroll at the end.

Also if I am using alot of API calls (which I do) I sometimes have a question before the form starts which says With API (yes/no) ands all my api calls have a If WithAPI = true then statement in front of them (obviously when my project is finninshed this is removed).

Hope this hasn't put you off using the code, you just have to be careful (and save your work often).

Cheers
GB
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Phil

Ever heard of the down arrow?:)
 
Upvote 0
Hello GB
Thanks again for helping with this. I will do as suggested.

Norie
Yes I have heard of the down arrow. It is still quicker to use the scroll wheel than the down arrow or are you saying you never use the scroll wheel in comboboxes or anywhere else for that matter.


Does anyone know if Excel 2007 supports this feature?

Regards

Phil
 
Upvote 0
Phil

No I don't use the scroll wheel in comboboxes.:)

Probably because my mouse seems to have a life of it's own sometimes.:eek:
 
Upvote 0

Forum statistics

Threads
1,213,486
Messages
6,113,932
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top