英文:
How to use a function or variable when defining a separate cell
问题
我正在尝试创建一个具有以下定义的动态饼图:
SERIES(,'2023'!$B$39:$B$46,'2023'!$AA$39:$AA$46,1)
其中$B$39:$B$46
是图例范围,$AA$39:$AA$46
是数据范围。
我的问题是如何使用来自另一个单元格的函数或值来定义$AA$39:$AA$46
,以使其根据其他输入变得动态。
我在单元格A1中有一个函数,它将单元格E33中的值转换为“AA”。该函数是:
=SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")
我想要在饼图数据的范围中使用此函数的输出。而不是$AA$39:$AA$46
,我想要使用要么单元格A1,要么实际方程=SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")
与行范围39:46
相结合。
所以,我的问题是是否可能将范围定义为:
$A1$39:$A1$46
,或者SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")$39:SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")$46
我可能没有很好地解释我的情况,但我将感激任何帮助。
英文:
I am trying to create a dynamic pie chart with the following definition:
SERIES(,'2023'!$B$39:$B$46,'2023'!$AA$39:$AA$46,1)
Where $B$39:$B$46
is the legend range and $AA$39:$AA$46
is the data range.
My question is how to define $AA$39:$AA$46
using a function or value from another cell to make it dynamic depending on other inputs.
I have a function in cell A1, which converts the value in cell E33 to "AA." The function is:
=SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")
I want to use the output from this function in the range used for the pie chart data. Rather than $AA$39:$AA$46
, I would like to use either cell A1 or the actual equation =SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")
combined with the row range 39:46
.
So, my question is whether it's possible to define a range as:
$A1$39:$A1$46
, orSUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")$39:SUBSTITUTE(ADDRESS(1, (E33), 4), "1", "")$46
I may not have explained my situation well, but I would appreciate any help.
答案1
得分: 2
你无法直接将这个公式直接放入图表的源定义中。您可以将这个公式(或任何提供所需范围的公式)放入一个命名范围(或命名公式)中,使用“公式”选项卡 > “名称管理器” > “新建”。指定一个名称并输入公式。如果您希望始终使用单元格 E33 中的值,请确保使用绝对引用,带有 $ 符号。
鉴于您的结果涉及到 AA 列,我假设单元格 E33 中的值为 27。您可以使用 Index() 函数来代替复杂的替代公式,如下所示:
=INDEX(Sheet2!$39:$39,Sheet2!$E$33):INDEX(Sheet2!$45:$45,Sheet2!$E$33)
将该公式放入一个命名范围中,然后将该命名范围插入图表数据源,如屏幕截图所示。
英文:
You won't be able to put this formula directly into the source definition for the chart. You can put this formula (or any other formula that delivers the desired range) into a range name (or named formula), using the Formulas Ribbon > Name Manager > New. Specify a name and enter the formula. Make sure to use absolute referencing with $ signs if you always want to use the value in cell E33.
Given that your result refers to column AA, I assume the value in cell E33 is 27. Instead of the complicated substitute formula, you can use Index() like this:
=INDEX(Sheet2!$39:$39,Sheet2!$E$33):INDEX(Sheet2!$45:$45,Sheet2!$E$33)
Put that formula into a range name and plug the range name into the chart data source as shown in the screenshot.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论