简体   繁体   English

Excel行/列和编号取决于另一个单元格

[英]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.

相关问题 按行 NUMBER 和列 LETTER 获取 Excel 单元格 - Get Excel Cell by row NUMBER and column LETTER Excel:如何查找列的第一行的值,具体取决于在同一列的另一行中查找给定数字的位置 - Excel: How to find the first row's value of a column depending on where to find a given number in another row of the same column 单元格中的格式取决于Excel中的行 - Formatting in cell depending on row in Excel 根据ms excel中另一列中的单元格选择,在消息框中显示单元格值(合并的单元格) - display a cell value (merged cell) on message box depending on cell selection in another column in ms excel 强制没有空单元格,取决于Excel中的另一个单元格 - Force no empty cell depending on another cell in Excel 来自Excel中另一个单元格的范围行号引用 - Range row number reference from another cell in Excel Excel如何输入带有列字母和行号的单元格(动态)否VBA - Excel How to input Cell with column letter and row number (dynamic) No VBA 获取Excel表中第一个单元格的行和列号 - Get row and column number of first cell in Excel table VBA Excel通过列和行偏移将单元格内容复制到另一个 - VBA Excel Copying Cell contents to another via column and row offset 锁定多个单元格,具体取决于另一个单元格中的数字 - Lock a number of cells depending on a number in another cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM