Option Buttons

Mustakrakish

New Member
Joined
Nov 7, 2011
Messages
5
Hi everybody,

I need to make a macro which will insert 3 option buttons in list, gives them names and adds to each one of them another macros i made.

So far i manage to do this:

Sub Swtich()
ActiveSheet.OptionButtons.Add(95.25, 30, 48, 17.25).Select
ActiveSheet.Shapes("Option Button 1").Select
Selection.OnAction = "PERSONAL.XLSB!srm_vlookup"
ActiveSheet.OptionButtons.Add(95.25, 30, 48, 17.25).Select
ActiveSheet.Shapes("Option Button 1").Select
Selection.OnAction = "PERSONAL.XLSB!b11_vlookup"
ActiveSheet.OptionButtons.Add(95.25, 30, 48, 17.25).Select
ActiveSheet.Shapes("Option Button 1").Select
Selection.OnAction = "PERSONAL.XLSB!t3_vlookup"
End sub

I do not know how to put buttons in line so they are not on each other and also change their names.

Main idea is to put in many sheet this buttons for changing data in one collumn so the user can compare different things with actuals.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Welcome to MrExcel.

The arguments for the Add method are Left, Top, Width and Height so change those to suit. You can assign the OptionButton to an object variable like this:

Code:
    Dim Opt As OptionButton
    Set Opt = ActiveSheet.OptionButtons.Add(95.25, 30, 48, 17.25)
    With Opt
        .Name = "Opt1"
        .OnAction = "PERSONAL.XLSB!srm_vlookup"
    End With
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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