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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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