简体   繁体   English

如果范围中的工作日与特定单元格相匹配,如何使用总和(如果要添加值)

[英]How to use sum if to add values if the weekdays in a range match a particular cell

I have an excel document that has 101 worksheets. 我有一个具有101个工作表的Excel文档。 100 of the worksheets contain data for a particular month ie one of the worksheets is called 'May 2010', followed by a worksheet called 'June 2010'. 100个工作表包含特定月份的数据,即其中一个工作表称为“ 2010年5月”,其后是一个工作表,称为“ 2010年6月”。 On each of these sheets there is a list of dates in column A, and a list of revenue $s in column B. 在每个工作表上,A列中都有日期列表,B列中有收入$ s列表。

I'm creating a summary sheet that is going to use the indirect function to look at all the different sheets and basically sum all of the revenue made on each day of the week in each month. 我正在创建一个摘要表,该表将使用间接函数查看所有不同的表,并基本上将每个月中每周的每一天所产生的所有收入相加。 For example I want to sum all the revenue made on Tuesdays in October of 2014. 例如,我想对2014年10月星期二的所有收入进行汇总。

I was trying to use an array function like so: 我试图像这样使用数组函数:

=SUM((--WEEKDAY(('May 2010'!A2:A22)=2)*(('May 2010'!B2:B22))))

I found this online. 我在网上找到了这个。 I am trying to see if i can sum all of the revenue values in column B on the sheet entitled 'May 2010' if the corresponding value in column A is a Monday. 我正在尝试查看是否可以对标题为“ 2010年5月”的工作表B列中的所有收入值求和,如果A列中的相应值为星期一。 The values in column A are of the form '11-May' A列中的值的格式为“ 11-May”

I think my problem is that i'm trying to check the weekday of a range of values but I'm not really sure. 我认为我的问题是我正在尝试检查某个值范围内的工作日,但我不确定。 I don't fully understand how array functions work or even if i'm supposed to be using them. 我不完全了解数组函数的工作方式,即使我应该使用它们也是如此。 I open to any suggestions as long as it doesn't require me to go through each of my 100 sheets manually and create a column that contains the weekdays of the corresponding dates. 只要不需要我手动检查每100张纸并创建一个包含相应日期的工作日的列,我就会接受任何建议。 Any thoughts? 有什么想法吗?

The short answer is that the brackets aren't quite right. 简短的答案是括号不太正确。

=SUM(((WEEKDAY('May 2010'!A2:A22)=2)*('May 2010'!B2:B22)))

or 要么

=SUMPRODUCT(((WEEKDAY('May 2010'!A2:A22)=2)*('May 2010'!B2:B22)))

if you prefer not to have to enter it as an array formula. 如果您不想不必将其作为数组公式输入。

If as @XOR LX suggests you actually want to repeat this over all of your sheets, it is a bit more tricky. 如果按照@XOR LX的建议,您实际上想在所有工作表上重复此操作,那会比较棘手。

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

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