How to make the spin button's linked cell vary

Irascivel

New Member
Joined
Jul 31, 2009
Messages
2
Hello all,

Let me explain what I pretend:

I have plotted a chart in excel for a product anual sales and forecasts. I've created a drop list to select the product upon which the graph is updated. That works perfectly.

But now I want to put a spin button next to the graph that changes a parameter in forecast's formula.
Depending on the chosen product, the spin button should change the respective parameter value for that product - which is also the linked cell for the button.

I've come with a simple code and put it in the Spin Button object, but it doesn't work (note that I'm not a vba expert....)
Code:
Code:
Private Sub SpinButton1_Change()
 
 
If Range("G10").Value = "PRODUCT A" Then
        SpinButton1.LinkedCell = Range("P105")
End If
 
If Range("G10").Value = "PRODUCT B" Then
        SpinButton1.LinkedCell = Range("AG105")
End If
 
If Range("G10").Value = "PRODUCT C" Then
        SpinButton1.LinkedCell = Range("AX105")
End If
 
If Range("G10").Value = "PRODUCT D" Then
         SpinButton1.LinkedCell = Range("BO105")
End If
 

End Sub  
</PRE>

What am I doing wrong?

Thanks for your help!


</PRE>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You almost had it!

Add the Address property to the cell assignment.
Code:
Private Sub SpinButton1_Change()
 
If Range("G10").Value = "PRODUCT A" Then
    SpinButton1.LinkedCell = Range("P105").Address
End If
 
If Range("G10").Value = "PRODUCT B" Then
    SpinButton1.LinkedCell = Range("AG105").Address
End If
 
If Range("G10").Value = "PRODUCT C" Then
    SpinButton1.LinkedCell = Range("AX105").Address
End If
 
If Range("G10").Value = "PRODUCT D" Then
    SpinButton1.LinkedCell = Range("BO105").Address
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,906
Messages
6,127,664
Members
449,397
Latest member
Bastbog

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