使用其他 Excel 单元格的字符串值表示公式中的 Excel 单元格地址?

发布于 2024-10-06 22:18:00 字数 393 浏览 0 评论 0原文

假设我想要这种类型的 formula = SUM(startcell:endcell) 的答案,但 startcellendcell 组件发生了变化。

因此,我不想直接在公式中使用 C1 来表示单元格 C1 中的值,而是希望能够使用 B1、B2 中的任何值和 B3 来构建可以在公式中表示 C1 的东西?

也许提出这个问题的更好方法是,Excel 有类似 Python 的 eval() 的东西吗?

替代文字

Say I want the answer to this type of formula = SUM(startcell:endcell) but the startcell and endcell components change.

So instead of using C1 directly in a formula to represent the value in cell C1, I want to be able to use whatever the values are in and B1, B2, and B3 to construct something that can represent C1 in a formula?

Perhaps a better way to ask the question is, Does Excel have something like Python's eval() ?

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云裳 2024-10-13 22:18:00

用文本解释 Excel 公式很乏味......我认为图像更好

alt text

HTH!

Explaining Excel formulas in text is tedious ... I think an image is better

alt text

HTH!

善良天后 2024-10-13 22:18:00

我认为更有用的是地址公式,它允许您根据指定的输入构建单元格地址字符串。表示法为 =ADDRESS(行号、列号、绝对号_标志、bool_A1Style、工作表文本)。

所以对于你的例子:
- 要返回 Sheet1!R1C3,您可以使用 =ADDRESS(B3,B2,,FALSE,B1)
- 要返回 Sheet1!C1,您可以使用 =ADDRESS(B3,B2,,TRUE,B1) 或 =ADDRESS(B3,B2,,,B1)

然后您可以在此返回的地址上使用 INDIRECT 函数。

请注意,如果您希望使用 sum() 函数对动态范围进行求和,则可以使用两个地址调用来构建整个范围的字符串。

EG 如果您在示例的单元格 C3 和 C4 中添加值 5 来指定最终单元格的行和列,则您可以使用 =ADDRESS(B4,B3,,,B2)&":"&ADDRESS 公式(C4,C3) 它将返回 'Sheet1!'!$C$1:$E$5

我还不能发布图像,所以希望这在文本中有意义!

I think that more useful is the address formula which allows you to build a cell address string from the inputs you have specified. The notation is =ADDRESS(row_number, column_number,absolute_number_flag,bool_A1Style,sheet_text).

So for your example:
- To return Sheet1!R1C3 you would use =ADDRESS(B3,B2,,FALSE,B1)
- To return Sheet1!C1 you would use =ADDRESS(B3,B2,,TRUE,B1) or =ADDRESS(B3,B2,,,B1)

You can then use your INDIRECT function on this returned address.

Note if you wanted a dynamic range to be summed using the sum() function you could use two address calls to build the string for the whole range.

E.G. If you added the value of 5 in cells C3 and C4 of your example to specify row and column for your end cell you could have a formula of =ADDRESS(B4,B3,,,B2)&":"&ADDRESS(C4,C3) which would return 'Sheet1!'!$C$1:$E$5

I can't post images yet so hopefully this makes sense in text!

海的爱人是光 2024-10-13 22:18:00

您可以尝试

formula = SUM(INDIRECT(B1),INDIRECT(B2),INDIRECT(B3))

并进行更多测试,看看您是否可以在范围内工作

You can try

formula = SUM(INDIRECT(B1),INDIRECT(B2),INDIRECT(B3))

And make more tests to see if you can work on ranges

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文