VBA changes Max Value of Slider depending on other cell.

Ochimus

New Member
Joined
Jul 14, 2011
Messages
2
Using Excel 2010 I have a dropdown in cell B2 (EVENT) linked by Data Validation to a range in Column E (SLIST) of a database (SCHEDULE).<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p> </o:p>
Each “event” has a different number of “active Days” listed in Column I.<o:p></o:p>
<o:p> </o:p>
I want the procedure to look at whatever is in B2, find the match in Column E, then make the number in Column I of that row the Max Value for the slider.<o:p></o:p>
<o:p> </o:p>
The Max Value will therefore change automatically when different “events” are selected in B2.<o:p></o:p>
<o:p> </o:p>
Tried using “INDEX/MATCH” as shown below but with no success<o:p></o:p>
<o:p> </o:p>
Code:
[COLOR=black][FONT=Verdana]Sub[/FONT][/COLOR][COLOR=black][FONT=Verdana] SETSLIDEVAL() 

ActiveSheet.Shapes.Range(Array("Scroll Bar 4")).Select 

With Selection 
.Value = 1 
.Min = 1 
'THIS NEXT LINE IS WHERE IT ALL GOES WRONG - DOESN'T LIKE "EVENT"
.Max = INDEX(SCHEDULE,MATCH(EVENT,SLIST,False),5) 
.SmallChange = 1 
.LargeChange = 10 
.LinkedCell = "C8" 
.Display3DShading = True 
End With 

End Sub [/FONT][/COLOR]
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Using Excel 2010 I have a dropdown in cell B2 (EVENT) linked by Data Validation to a range in Column E (SLIST) of a database (SCHEDULE).<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
Each “event” has a different number of “active Days” listed in Column I.<o:p></o:p>
<o:p></o:p>
I want the procedure to look at whatever is in B2, find the match in Column E, then make the number in Column I of that row the Max Value for the slider.<o:p></o:p>
<o:p></o:p>
The Max Value will therefore change automatically when different “events” are selected in B2.<o:p></o:p>
<o:p></o:p>
Tried using “INDEX/MATCH” as shown below but with no success<o:p></o:p>
<o:p></o:p>
Code:
[FONT=Verdana][COLOR=black][COLOR=black][FONT=Verdana]Sub[/FONT][/COLOR][COLOR=black][FONT=Verdana] SETSLIDEVAL() [/FONT][/COLOR]
 
[FONT=Verdana][COLOR=black]ActiveSheet.Shapes.Range(Array("Scroll Bar 4")).Select [/COLOR][/FONT]
 
[FONT=Verdana][COLOR=black]With Selection [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].Value = 1 [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].Min = 1 [/COLOR][/FONT]
[FONT=Verdana][COLOR=black]'THIS NEXT LINE IS WHERE IT ALL GOES WRONG - DOESN'T LIKE "EVENT"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black].Max = INDEX(SCHEDULE,MATCH(EVENT,SLIST,False),5) [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].SmallChange = 1 [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].LargeChange = 10 [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].LinkedCell = "C8" [/COLOR][/FONT]
[FONT=Verdana][COLOR=black].Display3DShading = True [/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End With [/COLOR][/FONT]
 
[FONT=Verdana][COLOR=black]End Sub [/COLOR][/FONT]
[/COLOR][/FONT]

I am surprised that you didn't get a different error message. To use a Worksheet Function in VBA code, it needs to be preceded by either Application, which only works for some of them, or WorksheetFunction, which works for all of them, like:

.Max = WorksheetFunction.INDEX(SCHEDULE,MATCH(EVENT,SLIST,False),5)

But I am not sure that even that would work with this particular formula.
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,270
Members
449,149
Latest member
mwdbActuary

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