Question : I would like to have a conditional function in a chart series.

I would like to have a conditional function in a chart series.
For example in the attached file I would like either chart1 or chart2 to appear on Sheet2 conditional on the contents of cell n28 or n29.  There could be up to 6 different data series and corresponding charts.
If cell n28 =yes then chart1 would appear on Sheet2, if cell n29=yes then chart2 would appear on Sheet2, etc.  I've tried using cell ranges and named ranges in the series value but get a message "That function is not valid"  For example: =IF(TestBook1.xlsx!R_1="Yes",TestBook1.xlsx!V_1,TestBook1.xlsx!V_2)
I would prefer not to use VBA (if it is even a possible solution) as we are using this in SharePoint 2003 and we have had problems in the past with enabling VBA in the SharePoint environment.
Thanks for any help.
   
 
 

Answer : I would like to have a conditional function in a chart series.

Hello dcruickshank,

this is a little tricky, but it can be done.

1. click Chart1 and copy it.
2. on sheet 2, right-click and use the past options to paste as a picture.  Now you have a picture of Chart 1 in your Sheet 2. We will now make this picture dynamic
3. Create range names for all the cell ranges that are beneath your chart. In the attached example, I have created

cChart1      =Sheet1!$J$71:$N$86
cChart2      =Sheet1!$J$88:$N$103

4. Create a range name with a formula that determines which chart to show. In the attached example, I have created

cChartShow      =IF(Sheet1!$N$28="yes",cChart1,cChart2)

In your final workbook, you probably want a formula like

=CHOOSE(MATCH("yes",$N$28:$N$33,0),cChart1,cChart2,cChart3,cChart4,cChart5,cChart6)

5. Click the chart picture on sheet 2 and in the formula bar enter:
=TestBook1.xlsx!cChartShow

The range name cChartShow will be set dynamically to one of the ranges that you defined in step 3 and the picture of the chart in Sheet 2 will reflect this range of cells.

see attached.

cheers, teylyn
Random Solutions  
 
programming4us programming4us