I have defined a named range and used it to feed data in a chart in excel. The data will start from row 11 (column B) and may reach until row 500, but usually it doesn't expands further than row 75. Some entries initially usually are #N/A. So, the first are #N/A, some data follows and then blank.
The problem is that sometimes the data is plotted correctly (i.e. only the data are picked and plotted, leaving out #N/A), but there are times that I get an empty chart, even if the #N/A are followed by numbers. I would like to leave #N/A in, because if I replace them by blank, the chart picks the blanks as zero and I don't want that.
In column A I have another named range that keeps the years, which are used as the x-axis for the chart. So, as example, my dataset looks like that: in column A from row 11 to 31 I have the years 1990-2010, in column B from row 11 to 18 I have #N/A, and from 19 to 31 numbers. After row 31 there are empty cells. Let's assume that is imported correctly in the chart. Then if I change the data in column with #N/A expanding now until e.g. B22, I get an empty chart. when I check the chart , it seems that it picked the data until eg B20, so I get an empty chart.
I suspect it has to do with the way I defined the range, but I cannot find a solution. Thanks in advance for any help.
答案 0 :(得分:0)
我找到了问题的解决方案。问题是由命名范围定义中的问题引起的。会发生什么是以下情况。假设您的列顶部有5#N / A,#N / As后面有10个值(有15个单元格的列)。当我定义命名范围时,excel会计算列中单元格的数量,但它没有考虑#N / As,因此计算10个单元格(而不是15个单元格)。当您尝试绘制系列(使用命名范围获取动态图表)时,Excel会从列的开头(即第一个#N / A)开始绘制图表。它记得它已经为该系列计算了10个值,因此它绘制了前5#N / As,然后是前5' true'值,省略其他5个值。
就我而言,我有以下代码来定义命名范围:
=OFFSET(sheet1!$AP$10,0,0,COUNT(sheet1!$AP:$AP)
从第10行的第10行开始。
为了解决#N / As问题,我们只需计算N / As的数量并将其添加回来:
=OFFSET(sheet1!$AP$10,0,0,COUNT(sheet1!$AP:$AP)+COUNTIF(sheet1!$AP:$AP,#N/A))
问题解决了。