Excel - 从单元格范围创建图表,同时排除空值?
我有这张 Excel 工作表,其中基本上包含大量数据。 现在,此 Excel 工作表通过导入数据的宏动态更新。因此数据可能会发生变化,这意味着某些单元格可能会被填充,而其他单元格则不会。
因此,我在工作表 2 中从 A2:A60 到 M2:M60 的每个单元格中都有这个公式,基本上如下所示:
=IF(Sheet1!E2<>0;Sheet1!A2;"")
意思是,如果我所在行的单元格 E2 为 0,则新电子表格中复制的值没什么。下一行也是如此:
=IF(Sheet1!E3<>0;Sheet1!A3;"")
重复直到第 60 行。
现在,我要做的是选择范围 A2:A60 并将该数据插入到图表中。但问题是,图表添加了没有值的单元格。我想将其从图表中排除,而不必更改图表的范围。可以在图表选择中使用公式吗?或者我必须使用宏?
编辑:现在,当我基于 A2:A60 创建图表时,图表看起来像这样。请注意,由于上述公式,只有 A4:A17 实际上具有任何值,其他值没有任何值。
I've got this Excel sheet which basically contains a lot of data.
Now, this Excel sheet is updated dynamically via a macro that imports the data. So the data might change, meaning, some cells might be populated, while others won't.
So I've got this formula in Sheet 2 in each cell from A2:A60 to M2:M60 which basically looks like this:
=IF(Sheet1!E2<>0;Sheet1!A2;"")
Meaning, if cell E2 on the row I'm in is 0, then the copied value in the new spreadsheet is nothing. Same goes for the next row:
=IF(Sheet1!E3<>0;Sheet1!A3;"")
This is repeated until row 60.
Now, what I want to do is to select the range A2:A60 and insert that data to a chart. But the thing is, the chart adds the cells that doesn't have a value. I want to exclude it from the chart without having to change the range of the chart. Is this possible using a formula in the Chart selection? Or would I have to use a macro?
Edit: Right now, the chart looks like this when I create it based on A2:A60. Notice that only A4:A17 actually have any value, the other ones have nothing, because of the formula described above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您也许可以使用命名范围。
您可以定义如下名称:
然后将它们用作图表中的源。
您可以找到更多信息 在 MS 网站上。
[编辑] 这里还有另外两个例子:
[编辑2]聊天中的工作结果:
问题:
COUNTA
公式不起作用因为单元格包含公式,所以即使值为空,COUNTA
仍然对这些单元格进行计数。解决方案:我们使用
SUMPRODUCT
公式来计算空值问候,
Max
You can probably use named range.
You can define names like :
And then use them as a source in your chart.
You can find more information on MS Website.
[EDIT] Here are two other examples:
[EDIT 2] Results of the work within the chat:
Problem: the
COUNTA
formula did not work on the worksheet because the cells contained formulas so theCOUNTA
still counted these cells even if the value was empty.Solution: we used the
SUMPRODUCT
formula to count the empty valuesRegards,
Max