[英]Formula in Google Spreadsheet to display the value of one cell in another cell where the number of columns between the cells is a controlled variable?
How do I create a formula in Google Spreadsheet which will display the value of one cell (eg cell A2) in another cell (eg C3) where the number of columns between the cells (n) is a controlled variable (in this example "2")? 如何在Google Spreadsheet中创建一个公式,该公式将显示另一个单元格(例如C3)中一个单元格(例如,单元格A2)的值,其中单元格之间的列数(n)是受控变量(在本示例中为“ 2 ”)?
Use case: I have a cash-flow model broken down by weeks in columns and want to show revenue 'n' number of weeks after deal has been signed, where I can manipulate one cell (representing the value of 'n') to see the impact on the model. 用例:我有一个按周细分的现金流量模型,并希望在签署交易后的几周内显示收入“ n”,我可以在其中操纵一个单元格(表示“ n”的值)来查看对模型的影响。
You use INDIRECT
for this. 您为此使用
INDIRECT
。
=INDIRECT("A"&n)
Where n
is your variable. 其中
n
是您的变量。 So, if n = 2
, you get A2
. 因此,如果
n = 2
,则得到A2
。 If n = 3
, you get A3
. 如果
n = 3
,则得到A3
。
EDIT: To reflect the change I made in the spreadsheet, here's the formula I used instead: 编辑:为了反映我在电子表格中所做的更改,这是我改为使用的公式:
=IFERROR(INDEX(6:6,1,COLUMN()-$B$14-1)*$B$13,0)
I had a similar issue when working on a character spreadsheet and the solution I got was to use offset. 在处理字符电子表格时,我遇到了类似的问题,而我得到的解决方案是使用偏移量。 The format is =offset(a,b,c) where a stands for the cell you want as your placeholder, in your example it would be a2.
格式为= offset(a,b,c),其中a代表您要用作占位符的单元格,在您的示例中为a2。 where b contains the value which will be moved over for rows (I actually have it targeting another cell so when I "level up" I can just change one box and everything dependent on it updates).
其中b包含将移至行的值(实际上,我将其定位到另一个单元格,因此当我“升级”时,我可以只更改一个框,所有依赖于它的内容都会更新)。 Where c contains the value to move over in columns.
其中c包含要在列中移动的值。 https://support.google.com/docs/answer/3093379?hl=en
https://support.google.com/docs/answer/3093379?hl=zh_CN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.