Trap worksheet scrolling?

Jorgen

Board Regular
Joined
Mar 25, 2004
Messages
67
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
When the user scrolls the worksheet (using a scroll wheel, or the scroll bars) I would like to have a VBA-code triggered, but in Excel 2003 there is no "VBA-event" for scrolling...

Is there any way of trapping that a scroll has happened, even if the selection didn't change?

Thanks!

Jörgen
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
You could possibly find some clever way to work in a ActiveWindow.VisibleRange.Address and watch it for changes - either periodically or when some other event occurs (like Selection_Change).
 
Upvote 0
Thanks Iliace,
I can see plenty of uses for "ActiveWindow.VisibleRange.Address".

The problem for me is that it is the event I need to catch, because it will not have any change associated with the scrolling. So what I am looking for is to get a code triggered when the scrolling takes place, rather than check every 2 seconds if there has been a scrolling...

Thanks,
//Jörgen
 
Upvote 0
Why do you need to capture scrolling? You could hide the scrollbars. Then the user would have to use the Page keys and the Worksheet_SelectionChange event would fire.
 
Upvote 0
Hi Andrew,
Thanks for answering.
As they scroll down, I want a shape to move within the sheet with the scrolling. So they are allowed to scroll, but I need to know when they do it to trigger the vba for moving the shape.
//Jörgen
 
Upvote 0
You could subclass the workbook window and try and intercept the WM_SCROLL and WM_VSCROLL messages but in my experience this tends to be pretty unstable and often freezes Excel. Can you use a floating toolbar instead?
 
Upvote 0
Why not just put the shape at the top of the worksheet and use Window>Freeze panes?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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