activex scroll bar

charly1

Board Regular
Joined
Jul 18, 2023
Messages
87
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have an ActiveX scrollbar control on my worksheet. It has been used to create a "scrollable table". (Using the offset function, which returns the data from a range of cells that contain a data spill).
I would like the max value for the scrollbar to be a dynamic number, always referring to the currently last cell of the spilled data. Meaning that I would never be able to actually scroll down into empty cells.

Any help would be greatly appreciated!

Thanks in advance!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You'd need code to do that. An alternative would be to alter your OFFSET formula to limit the rows returned based to the lesser of the scrollbar value and the actual data count.
 
Upvote 0
Thanks for your quick reply.

I understood that I would need code, my problem was how exactly to write that code?
 
Upvote 0
Probably something like a Worksheet_calculate event - for example:

Code:
private sub worksheet_calculate()
me.scrollbar1.max = range("A1").spillingtorange.rows.count
end sub
 
Upvote 1
Solution
Probably something like a Worksheet_calculate event - for example:

Code:
private sub worksheet_calculate()
me.scrollbar1.max = range("A1").spillingtorange.rows.count
end sub
Thanks So Much for your time. It worked perfectly.

Quick q, was there a specific reason why you wanted to place the code in a worksheet calculate event and not in a scrollbar change event?
 
Upvote 0
If it's in the Change event, it won't actually update until after you scroll, which could lead to some odd effects. In the calculate event, it will be updated as soon as the source data changes.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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