[英]Excel Row/Column and number depending on another cell
I have a cell which has to have a relative content based on another cell. 我有一个单元格,该单元格必须具有基于另一个单元格的相对内容。 For example: if cell A1 has value 4, cell B1 has to take its content from cell "=B(4+2)". 例如:如果单元格A1的值为4,则单元格B1必须从单元格“ = B(4 + 2)”中获取其内容。 In the similar manner, cell C1 has the column value based on the content of another cell. 以类似的方式,单元格C1具有基于另一个单元格的内容的列值。 So if the A2 cell value is 6, C1 should take its value from C+6=I column and row 1, something like "=(C+A2)1". 因此,如果A2单元格值为6,则C1应从C + 6 = I列和第1行中获取其值,例如“ =(C + A2)1”。 Would be great being able to use relative column and relative row! 能够使用相对列和相对行会很棒!
Is it possible? 可能吗? I was expecting a syntax similar to "=B(1+4)" but doesn't work. 我期待的语法类似于“ = B(1 + 4)”,但不起作用。
For your first question. 对于第一个问题。
How to get "=B(4+2)" 如何获得“ = B(4 + 2)”
=INDIRECT("B" & A1 + 2)
Your second question. 你的第二个问题。
How to get "=(C+A2)1" 如何获得“ =(C + A2)1”
=INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(C1)+A2,4),"1","") & 1)
The formula =SUBSTITUTE(ADDRESS(1,COLUMN(C1),4),"1","")
is used to get the column letter. 公式=SUBSTITUTE(ADDRESS(1,COLUMN(C1),4),"1","")
用于获取列字母。 This gives you C. Here to get column I
ie C+6
I wrote =SUBSTITUTE(ADDRESS(1,COLUMN(C1)+6,4),"1","")
. 这样就得到了C。在这里获得列I
即我写的C+6
=SUBSTITUTE(ADDRESS(1,COLUMN(C1)+6,4),"1","")
。 So the second formula turns out be =INDIRECT(I & 1)
所以第二个公式变成=INDIRECT(I & 1)
and an alternate form using OFFSET (not advised if using multiple times) is: 使用OFFSET的替代形式(如果多次使用,则不建议使用)是:
=OFFSET($B$2,A1,0,1,1) =偏移量($ B $ 2,A1,0,1,1)
and using INDEX (preferred if you have lots to do) is: 并使用INDEX (如果有很多事情可做):
=INDEX(B:B,2+A1)
For you other option about traversing columns you can use the exact same formula by changing up your offset direction or reference array in the index as follows: 对于遍历列的其他选择,您可以通过如下方式更改索引中的偏移方向或引用数组来使用完全相同的公式:
=OFFSET($C$1,0,A2,1,1)
OR
=INDEX(1:1,COLUMN(C1)+A2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.