Form controls can be added to an Excel spreadsheet to create interactivity with the user. This article looks at using option button controls to allow a user to choose the data they want to see on a chart.
The first thing you need to do is have the raw data somewhere on the worksheet. For this example, there are four small tables of data showing the top 5 goal scorers from the Premier League, La Liga, Serie A and the Bundasliga.
The goal is to have an option button for each league. The user can then click on the league they want to view, and the chart will change to show the user the appropriate goal scorers.
Insert the Option Buttons
To insert the option buttons onto the spreadsheet you will need to have the Developer tab on the ribbon.If you do not already have this, click the Office Button > Excel Options, click the Show Developer tab in the Ribbon option and click Ok.
Now to insert the option buttons in Excel;
- Click the Developer tab on the Ribbon
- Click the Insert button in the Controls group
- Click on the Option
Button under the Form Controls header
- Click on the spreadsheet where you want to position the control and repeat this step for the number of option buttons that you need
- Right click on each option button in turn and select Edit Text to change the label that accompanies the button. Alternatively you can enter the label in the adjacent cell which is the approach taken in this example
Specify the Cell Link
For the option buttons to work you need to specify a cell to hold the user response.
- Right click on one of the controls and select Format Control from the shortcut menu
- Click in the Cell Link box and then select the cell on the spreadsheet that you want to use
- Click Ok
Now when you click on one of the option buttons the result of 1, 2 or 3 and so on will appear in the cell you chose. This number represents the button you clicked on.
Create the Chart Data Source
The next step is to create the data source for the chart. This table of data will change depending on the option button selection.
The formula below is used to check the cell linked to the action buttons to see what number is in it, and then display the data from the appropriate league.
This formula is then copied to the required cells.
The CHOOSE function checks cell B9 to see what option was selected. Then displays the content of the cell from the appropriate index number e.g. If the cell contains 1 then display Premier League data, if it displays 2 then show La Liga data and so on.
Create the Interactive Chart
The last step is to create the chart from the interactive data source that was just created.
- Select the cell range you want to use
- Click the Insert tab on the Ribbon
- Click the Column Chart button and select Clustered Column
In a real scenario steps would be taken to tidy the workbook up including hiding the gridlines and hiding the cell holding the option button response and cells being used for the chart data source.
This data is untidy and would usually be placed on a separate sheet entirely, or on hidden columns so as not to confuse the user.
This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.
Unknown on March 25, 2020:
I have 1 question.
I already created the excel charts.
Can I create buttons on these charts such that when i click on the chart it brings me to my source data sheet.
Sreenivasan on March 22, 2019:
if i selected radio button a image should be displayed below
Ashu on April 22, 2013:
Hey Thanks I got solution.
But now my problem is.. in my one field it contain percentage and in one column its simple Value.
and when I select percentage eg- 34% our formula shows 0.34 value.
while it works fine in simple value.
what to do now.
Ashu on April 22, 2013:
OK I got it. but below B9 cell.
how it is displaying whole data for selected cell.
Sue on June 21, 2012:
Alan on May 08, 2012:
You will just need to enter more or less goalscorers and change the chart data source to match the range. The same technique will be used, you will just need a larger or smaller range.
Urbi on April 19, 2012:
how to change this if I have more or less goal scorers?
Vasyl on July 28, 2011:
Thanks a lot