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
 
Norie: I already have the top rows frozen for other reasons, so this is placed in the left (lower) pane which will scroll.

Rorya: Yes, since catching a scroll seems very complicated and I don't want to mess up Excel, I will try a floating toolbar. And of course I immediately ran into problems. If I need a couple of buttons on it, and place it to the left, how do I get the buttons under each other while still being read left-to-right? Like:
________
| Print |
|_______|
________
| Copy |
|_______|
________
| Change|
|_______|

(forgive the bad graphics)
Thanks,
Jörgen
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try this (adjust macro names as required):
Code:
Sub addbar()
    Dim cbr As CommandBar, ctl As CommandBarControl
    Set cbr = CommandBars.Add("Tester", , , True)
    Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
    With ctl
      .Caption = "Print"
      .OnAction = "PrintMacro"
      .Style = msoButtonCaption
   End With
    Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
    With ctl
      .Caption = "Copy"
      .OnAction = "CopyMacro"
      .Style = msoButtonCaption
   End With
    Set ctl = cbr.Controls.Add(msoControlButton, , , , True)
    With ctl
      .Caption = "Change"
      .OnAction = "ChangeMacro"
      .Style = msoButtonCaption
   End With
    With cbr
      .Position = msoBarFloating
      .Height = 100
      .Width = 50
      .visible = True
   End With
End Sub
 
Upvote 0
Rorya: Thanks! My problem seems to be that I docked it to the left side, and then the tool-bar orients itself funny.

Richard: Thanks for the link to Jaafars solution! If I can find the example-file it might be a very workable solution!

//Jörgen
 
Upvote 0

Forum statistics

Threads
1,215,105
Messages
6,123,114
Members
449,096
Latest member
provoking

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