简体   繁体   English

如何在公式中使用单元格的文本?

[英]How to use a cell's text in a formula?

My Excel file has eight different worksheets. 我的Excel文件有八个不同的工作表。 Seven of them are named to the days of the week ("Monday", "Tuesday", etc.). 其中七个被命名为星期几(“星期一”,“星期二”等)。 The last worksheet, called "Week" should provide some general data, based on these days. 最近的工作表称为“周”,应根据这些天提供一些常规数据。

In the first column of "Week", I typed the days of the week, so A1: Monday , A2: Tuesday , etc. In the second column, I'd now like to add a formula that uses data from the worksheet of the corresponding day. 在“周”的第一列中,我键入了星期几,因此输入A1: MondayA2: Tuesday等。在第二列中,我现在想添加一个公式,该公式使用该工作表中的数据相应的一天。 For example: B1: =SUMIF(Monday!C1:C4;mycondition;Monday!D1:D4) , B2: =SUMIF(Tuesday!C1:C4;mycondition;Tuesday!D1:D4) , etc. This works fine, but I don't want to type the days of the week all over again. 例如: B1: =SUMIF(Monday!C1:C4;mycondition;Monday!D1:D4)B2: =SUMIF(Tuesday!C1:C4;mycondition;Tuesday!D1:D4)等等,这工作正常,但是我不想再次输入星期几。

Is it possible to use the text of the cells A1-A7 in "Week" in these formulas? 在这些公式中是否可以在“周”中使用单元格A1-A7的文本? I tried =SUMIF(A1!A1:A4;mycondition;A1!B1:B4) , but that didn't work. 我尝试了=SUMIF(A1!A1:A4;mycondition;A1!B1:B4) ,但这没有用。


Note: If I should add a new row to one of the "day" worksheets, the cell references in the formula in "Week" should be changed too. 注意:如果我应在“ day”工作表之一中添加新行,则“ Week”中公式中的单元格引用也应更改。 =SUMIF(INDIRECT(A1&"!C1:C4");mycondition;INDIRECT(A1&"!D1:D4")) isn't what I'm looking for, because it fixes C1:C4 and D1:D4 . =SUMIF(INDIRECT(A1&"!C1:C4");mycondition;INDIRECT(A1&"!D1:D4"))不是我要的,因为它修复了C1:C4D1:D4

Use INDIRECT function: 使用INDIRECT函数:

=SUMIF(INDIRECT(A1&"!$C:$C");mycondition;INDIRECT(A1&"!$D:$D"))

(I'm not sure if the syntax is correct (,/;), I dont't have an English Excel version.) (我不确定语法是否正确(,/;),我没有英文Excel版本。)

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

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