简体   繁体   English

EXCEL公式,用于返回不同日期范围(在ROW中)和不同乘积(在COLUMN中)的SUM

[英]EXCEL Formula to return a SUM for a different date range (in ROW) and a different product (in COLUMN)

I have a spreadsheet of product sales by day. 我有一天的产品销售电子表格。 There are thousands of Products that were updated on different days. 成千上万的产品在不同的日期进行了更新。 Each Product is in a separate column (designated by a Product ID). 每个产品都在单独的列中(由产品ID指定)。 Each row is a different day. 每行是不同的一天。

I am looking for a formula that will sum the sales for each product since the day it was updated. 我正在寻找一个公式,用于汇总自更新之日起每种产品的销售额。

So there are 2 moving parts for the formula, identifying which column to sum by the product ID, and then sum from the date it was updated onwards. 因此,该公式有2个移动部分,分别根据产品ID标识要累加的列,然后从更新日期算起。 I have been able to isolate the Date row using 我已经能够隔离使用

*=MATCH(F159,Sheet!A:A,0)* 

and the Column reference using 和列引用使用

*=SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")* 

but I haven't been able to incorporate these into a formula that will then sum. 但我无法将这些内容合并到可以求和的公式中。

Any help would be grreatly appreciated, thanks! 任何帮助将不胜感激,谢谢!

It's probably easiest to do with a SUMIF formula, so assuming you have a specific product in column H then you can use this formula to sum for that product for sales on and after a specific date 使用SUMIF公式可能最简单,因此,假设您在H列中有特定产品,则可以使用该公式求和该产品在特定日期及之后的销售额

=SUMIF(A:A,">="&Y2,H:H)

where your reference date is in Y2 您的参考日期在Y2

Now you want the product to be dynamic too so with a specific product in Z2 you can expand that SUMIF like this to get the sum column dynamically 现在,您也希望产品也是动态的,因此对于Z2中的特定产品,您可以像这样扩展SUMIF以动态获取sum列

=SUMIF(A:A,">="&Y2,INDEX(B:X,0,MATCH(Z2,B$1:X$1,0)))

so that will find the correct column to sum, assuming product data in columns B to X (expand as required) with product name in row 1 因此,假设B到X列中的产品数据(根据需要扩展)的产品数据在第1行中,则将找到正确的列进行汇总

Making a few assumptions as to your variable formats, try this: 对变量格式进行一些假设,请尝试以下操作:

Sub Macro1()
    row = MATCH(F159,Sheet!A:A,0)
    col = SUBSTITUTE(ADDRESS(1,K159,4,1,),"1","")
    lastrow = Range(col).End(xlDown).Row

    Set rng = Range(col & Row & ":" & col & lastrow)

    Range("B1").Value = Excel.WorksheetFunction.Sum(rng)
End Sub

您是否在Excel中尝试过数据透视表?

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

相关问题 需要帮助,Excel公式,计算与不同范围内容匹配的范围内的单元格数 - Need help, Excel Formula, Count number of cells in a range that match the content of a different range Excel公式为等于,空白或数值计数的所有单元格返回不同的结果 - Excel formula to return different results for all cells equal to, blank or count of a value Excel百分比数组公式,用于日期范围内的值 - Excel Percentile Array Formula for Values within Date Range 返回序列号列表的命名范围中的Excel数组公式 - Excel Array Formula in Named Range to Return List of Sequential Numbers Excel公式对给定列号列表中的所有单元格求和? - Excel formula to sum all cells that are in a list of given column numbers? 在公式中使用索引、匹配和行/列 excel 函数返回一个子集数组,其中仅包含带文本的单元格并排除空单元格 - Use index, match, and row/column excel functions in a formula to return a subset array with just cells with text and exclude the empty ones excel不同的SUM.IF数组函数 - excel different SUM.IF array function (数组公式?)Excel 返回下一个股价反弹的日期 - (array formula?) Excel to return the next date of a stock price rebounding 用公式定义求和/求和的范围 - Define range for sum/sumif with a formula 使用数组改变 Excel 公式中偏移量中的行/列 - Use array to vary the row/column in an offset in Excel formula
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM