Formula or VBA for a Scroll bar to match min and max values of a variable cell?

gaftalik

Well-known Member
Joined
Feb 6, 2003
Messages
521
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone,

In a table i have :
E1= Apple; F1= 0.2%; G1= 1.5%
E2= Banana; F2= 1.5%; G2= 3%
E3= Pear; F3= 1%; G3= 4%
E4= Cherry; F4= 4% ; G4= 10%
E5= Peach; F5= 5% ; G5= 20%

Column F represents the minimum % and column G represents maximum %

In A1 i have a data validation drop down list E1:E5 (Apple,Banana;Pear,Cherry,Peach)

Whatever selection of A1 value, i need a scroll bar form linked to cell "C1" to automatically set the minimum & the maximum values matched in F1:G5

Ex: If A1= "Pear" the scroll bar should scroll down C1 to a min of 1% and scroll up a max of 4%
If A1= "Peach" it should scroll down C1 to a min of 5% and scroll up a max of 20%

Could that be done with a formula? cause i dont know VBA, if so would you kindly find the easiest VBA code with instructions please?

I appreciate very much your support !
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi,

Does this suit?


Book1
ABCDEFGH
1Peach20.0%FruitsMinMaxDV
2Apple0.2%2%0.05
3Banana1.5%3%0.2
4Pear1%4%
5Cheery4%10%
6Peach5%20%
Sheet1
Cell Formulas
RangeFormula
H2=VLOOKUP($A$1,$E$2:$G$6,ROWS($H$1:H2),0)
H3=VLOOKUP($A$1,$E$2:$G$6,ROWS($H$1:H3),0)
 
Last edited:
Upvote 0
Thank you for your reply.
Your formulas lookup the min and max and returns it in cells, what i need exactly is that the scroll bar linked to C1 to be set to a max of H3 and minimum of H2 meaning that the scroll bar should not scroll down to less than 5% and not to scroll up more than 20 % as in your Peach example.

Sorry the scroll bar was not generated by the html maker, it's between C7 and B7


Book1
ABCDEFGHI
1Peach5%FruitsMinMaxDV
2Apple0.20%1.50%0.05
3Banana1.50%3.00%0.2
4Pear1.00%4.00%
5Cherry4.00%10.00%
6Peach5.00%20.00%
7MinMax
85%20%
9Cell link = $C$1
10
11
Sheet1
Cell Formulas
RangeFormula
H2=VLOOKUP($A$1,$E$2:$G$6,ROWS($H$1:H2),0)
H3=VLOOKUP($A$1,$E$2:$G$6,ROWS($H$1:H3),0)
 
Last edited:
Upvote 0
Hi everyone,

I found the following vba code which solved the problem :

Code:
Private Sub ScrollBar1_Change()
ActiveSheet.ScrollBar1.Max = Range("$H2").Value
ActiveSheet.ScrollBar1.Min = Range("H3").Value
End Sub

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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