获取给定行号和列号的单元格内容
我想获取给定行号和列号的单元格的内容。行号和列号存储在单元格中(此处为 B1、B2)。我知道以下解决方案有效,但感觉有点hacky。
Sol 1
=CELL("contents",INDIRECT(ADDRESS(B1,B2)))
Sol 2
=CELL("contents",OFFSET($A$1, B1-1,B2-1))
有没有更简洁的方法? (比如 =CellValue(row,col) 或其他)?
编辑/澄清: 我只想使用 Excel 工作表公式。没有VBA。简而言之,我几乎寻找与 VBA Cells() 方法等效的 Excel 公式。
I want to get the content of a cell given its row and column number. The row and column number are stored in cells (here B1,B2). I know the following solutions work, but they feel a bit hacky.
Sol 1
=CELL("contents",INDIRECT(ADDRESS(B1,B2)))
Sol 2
=CELL("contents",OFFSET($A$1, B1-1,B2-1))
Is there no less verbose method? (like =CellValue(row,col) or whatever)?
Edit / Clarification:
I just want to use the excel worksheet formulas. No VBA. In short, I pretty much look for the equivalent of the VBA Cells() method as an excel Formula.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不需要公式的 CELL() 部分:
或者
两者都可以工作。请注意,
INDIRECT
和OFFSET
都是易失性函数。易失性函数会减慢计算速度,因为它们在每次重新计算时都会进行计算。You don't need the CELL() part of your formulas:
or
will both work. Note that both
INDIRECT
andOFFSET
are volatile functions. Volatile functions can slow down calculation because they are calculated at every single recalculation.尝试 =index(ARRAY, ROW, COLUMN)
其中:
数组:选择整个工作表
行、列:您的行和列引用
对于那些查看公式的人来说应该更容易理解。
Try =index(ARRAY, ROW, COLUMN)
where:
Array: select the whole sheet
Row, Column: Your row and column references
That should be easier to understand to those looking at the formula.
我花了一段时间,但这就是我如何让它变得充满活力。它不依赖于排序表。
首先,我从一列州名称(A 列)和每个州的一列飞机(B 列)开始。 (第 1 行是标题行)。
查找包含飞机数量的单元格是:
我将其放入一个单元格中,然后给该单元格命名为“StateRow”
然后使用上面的提示,我得到了以下结果:
这从第 1 列“StateRow”行中的动态值返回状态名称
现在,随着输入更多数据,计数列中的值会随着时间的推移而变化,我总是知道哪个州拥有最多的飞机。
It took me a while, but here's how I made it dynamic. It doesn't depend on a sorted table.
First I started with a column of state names (Column A) and a column of aircraft in each state (Column B). (Row 1 is a header row).
Finding the cell that contains the number of aircraft was:
I put that into a cell and then gave that cell a name, "StateRow"
Then using the tips from above, I wound up with this:
This returns the name of the state from the dynamic value in row "StateRow", column 1
Now, as the values in the count column change over time as more data is entered, I always know which state has the most aircraft.