I have several data in excel sheet and I wonder if its possible (through macros or something else) to select the data and display the series needed.
I'm not quite sure if I explained the situation correctly...
But I have multiple curves, and instead of plot the average curve or single curves, I would like to have the option to plot: curve 1, curve 2, curve 3, average curve...
Kind regards,
DNA
My preferred way to do this is with a combination of a couple of ideas. In general, Excel charts are easiest to maintain if they are looking at a simple range instead of complicated named ranges. Given this, I like to create a simple column of data for the chart and then use other Excel features to modify that column of data.
Note that the steps below are for a specific case of a block of data all on one sheet. There are a ton of variations that you can do to make this work for other configurations. The idea is simple: create a new column of data for the chart and use normal formulas to get the data there. You can make the x-axis a selector as well.
For the simple case of a common x-axis with varying series for the y-axis all in one block of data, I do these steps:
Start = block of data
- Add a column header off to the side which will "drive" the selection. I like to make this a Data Validation drop down so that the selection is correct. I did this in
G2
, selecting the column headers as the Source
.
- With this in place, you can use the selection there to update the data in the column below it. A simple formula for doing this uses
INDEX
.
Formula in G3
, copied down to end of data: =INDEX($C$3:$E$25,,MATCH($G$2,$C$2:$E$2,0))
This formula works by finding the column name in the list of column headers and returning that column of data. Since the row selection is blank ,,
, it relies on the relative position of the cell which works since everything is lined up.
- Once this is done, you can then create the chart simply using the date and the new column of data. It will respond to changes in the selector which works nicely. If you use the column
G
header as the series name, that will update too which is a good effect for free. Below is the chart showing the ranges it is using.