Buttons & Macros

Vytfla

New Member
Joined
Apr 26, 2011
Messages
11
I'm pretty much a novice at Excel, so bear with me while I try to explain this in the easiest way I think is possible. I'm trying to have fields that, when a specific button is clicked, display numbers (or even pictures if that is possible).

Say (for example) a1:a3 say strength, health, and magic, respectively, and I have three buttons over to the side- warrior, rogue, mage. I want b1:b3 to show the stats of the respective class when I click the appropriate buttons (so if I clicked mage, b1 would be 9, b2 = 5, and b3 = 30). How would I do something like that? I know how to create buttons and assign macros to them, but I don't know how to do the specific thing I want.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Assigned to Mage Button
Code:
Sub MageButton()
    Range("B1") = 9
    Range("B2") = 5
    Range("B3") = 30
End Sub
 
Upvote 0
For mage. Assign to ActiveX button. You can tailor the others as needed. Experiment with the record macro feature.

Code:
Private Sub CommandButton1_Click()
 
'for mage
Range("B1").Value = "9"
Range("B2").Value = "5"
Range("B3").Value = "30"
    
End Sub
 
Upvote 0
If I have a 10 buttons, that when clicked, will change the same cells; how can I write a function that does that without having to create 10 macros?
 
Upvote 0
I would suggest making a dropdown using data validation.

and then playing around with this function using named ranges:
<CODE>=SUMIFS(INDIRECT($C$21),Sales_Per,B24,Product,$C$19,Period,$C$20)</CODE>
<CODE></CODE>
<CODE>You could even forgo the dropdown and just type the specific class exactly as it is defined in your data range.</CODE>
<CODE></CODE>
 
Upvote 0
I would suggest making a dropdown using data validation.

and then playing around with this function using named ranges:
<CODE>=SUMIFS(INDIRECT($C$21),Sales_Per,B24,Product,$C$19,Period,$C$20)</CODE>
<CODE></CODE>
<CODE>You could even forgo the dropdown and just type the specific class exactly as it is defined in your data range.</CODE>
<CODE></CODE>

Thanks for replying. I got some help from a different forum.
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

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