简体   繁体   English

在公式中引用另一个单元格中的变量值

[英]Reference a variable value in another cell as part of formula

SHORT QUESTION 简短问题

Ive got a formula =IF(ISBLANK(Q.1!C71),"",Q.1!C71) im trying to be able to set a control cell / variable so instead of C71 it would reference c*$B$1* , *$B$1* being my reference / control cell / variable in the same sheet as this formula, any ideas how to do this ? 我有一个公式=IF(ISBLANK(Q.1!C71),"",Q.1!C71)我试图设置控制单元格/变量,所以它会引用c*$B$1*而不是C71*$B$1*是我与此公式相同的工作表中的参考/控制单元/变量,您对此有何想法?


LONG QUESTION 长问题

Ive got a spreadsheet that is regularly provided by a 3rd part with different data in it each time, although the column order of the data is always the same. Ive有一个电子表格,该电子表格通常由第3部分提供,每次中都有不同的数据,尽管数据的列顺序始终相同。

To get the data into my spreadsheet, i create another tab in the same workbook as their sheet and reference the data in their spreadsheet in a sheet i call import template sheet, i then from there copy and paste the import sheet into my spreadsheet, as all the columns match. 为了将数据输入到电子表格中,我在与工作表相同的工作簿中创建了另一个标签,并在工作表中引用其电子表格中的数据(称为导入模板表),然后从那里将导入表复制并粘贴到我的电子表格中,如下所示:所有列都匹配。

To reorder their columns in a non destructive way i use the following formula in my import template sheet, for instance if i wanted their column C, in my sheets column F i would place this in F1 and the pull the cell down so it does this for all rows : 为了以一种非破坏性的方式对它们的列进行重新排序,我在导入模板表中使用以下公式,例如,如果我想要它们的列C,则在我的表列F中将其放置在F1中,然后将单元格下拉,这样就可以了对于所有行:

=IF(ISBLANK(Q.1!C71),"",Q.1!C71) (the ifblank just helps sanitise the data by not throwing #ref if there is no data in the cell.) =IF(ISBLANK(Q.1!C71),"",Q.1!C71) (如果单元格中没有数据,ifblank不会抛出#ref来帮助清理数据。)

The issue i have is that i have around 30 columns to re order and although the column structure is the same, there is sometimes some 'header' data (basically a text summary) at the top of the document of varying length, so instead of the first row i need being 71 sometimes it might be row 50 or row 90 ... 我遇到的问题是,我有大约30列要重新排序,并且尽管列结构相同,但有时文档顶部的某些“标题”数据(基本上是文本摘要)的长度会有所不同,因此,第一行我需要为71有时可能是50行或90行...

To speed things up id like to be able to have a control number / variable cell where i can set a variable for the starting row, and then reference that in my cell, so that i dont have the go and edit the formula in 30 different columns. 为了加快id的速度,我希望能够拥有一个控制号/变量单元格,在其中我可以为起始行设置一个变量,然后在我的单元格中引用该变量,这样我就不必再去编辑30种不同的公式了列。

If you want to control the starting row of the reference by putting a number in cell B1 , that would look something like this: 如果要通过在单元格B1放置数字来控制引用的起始行,则应如下所示:

B1 B1

71

Referencing Cell 参照单元

=IF(ISBLANK(INDIRECT("Q.1!C"&B1),"",INDIRECT("Q.1!C"&B1))

INDIRECT allows you to build a string representation of a cell reference and then get the value of that cell. INDIRECT允许您构建单元格引用的字符串表示形式,然后获取该单元格的值。 So we build a string reference using the value of B1, and then use INDIRECT to get the value of that string's referenced cell. 因此,我们使用B1的值构建字符串引用,然后使用INDIRECT获取该字符串的引用单元格的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM