using form controls to select colums from a data table to populate a graph

Benjamin92

New Member
Joined
Feb 15, 2015
Messages
3
Hi all, thank you in advance for your help. I've been working on an Excel project at work this past week, and am stumped. I'm looking for a way to use form controls from the developer tab to make 1 graph, but select different columns from a data chart to populate the graph.

I have a data table with the following 5 column titles: 1. mm/yy 2. score 3. district score 4. regional score 5. top 20%.
My goal is to use this data table to populate one graph, and use form controls to either select columns 1,2,3,and 4, or use columns 1,2,and 5 to populate the graph.

Any thoughts on the best way to do this?

Thank you!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Okay, here's how I would approach it. This is some dummy data I'm starting with and a chart of all of the series.

MrExcelChartByOptionButton1.png


What I'm going to do is add some columns (F:I) that show or don't show data based on which of two option buttons is selected, and I'm going to make my chart from all of the data. When the values aren't shown in the worksheet, they will not appear in the chart.

Here's my new data range. At first the formula in cell F2 (and copied into the entire range F2:I13) is simply

Code:
=B2

I then add two option buttons and label them Chart A and B. I right click on one of them (doesn't matter which) and select Format Control, and on the Control tab, I click in the Cell Link box, and select cell K1. This cell tells me which of the buttons is selected, 1 or 2.

MrExcelChartByOptionButton2.png


So I select A1:A13, then hold Ctrl while selecting F1:I13, and insert a line chart (below left). I delete the legend and instead label the last point in each series with the series name, and use label text that matches each series color (below right).

I keep the formulas in column F the way they are, since this series appears whichever option is selected. The formula in G2 (copied into G2:H13) is

Code:
=IF($K$1=1,C2,NA())

Which means show the value if the first option button is selected, or show #N/A instead. #N/A isn't plotted in a line or scatter plot.

Similarly in I2 (and filled into I2:I13) is this formula

Code:
=IF($K$1=2,E2,NA())

When the first option button is selected, I get Chart A (bottom left), and when the second is selected, I get Chart B (bottom right).

MrExcelChartByOptionButton3.png
 
Upvote 0
Thank you for the step-by-step! It worked perfect and did exactly what I needed to do. Previously I had each graph mapped (one compared to district and region, one compared to top 20%), and was using an index,match function to pull the appropriate graph. The file size was way to big, and this shrunk it in half!

One more question, if you don't mind. Is there a way to hide the new tabs (F:I) without losing their function? When I hid them, they would no longer work to populate the graph.

Thank you!
 
Upvote 0
You could stick the calculations in another sheet, and hide the sheet. Alternatively, you can hide the columns, and then you need to tell each chart to plot hidden cells:

Edit Data > Hidden and Empty Cells button (bottom left of dialog) > [X] Show data in hidden rows and columns.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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