[英]How can I vlookup across rows with title rows as criteria in Excel/VBA?
Data: 数据:
Output: 输出:
Hello, please see attached sheet. 您好,请参阅附页。 I have sheets with financial data organized by an ID column and by date rows in titles. 我的工作表包含由ID列和标题中的日期行组织的财务数据。
On sheet 1, I want to specify a date range in sheet 1 cells B1 & D1 for which profit margin would be calculated. 在工作表1上,我想在工作表1单元格B1和D1中指定日期范围,以计算利润率。 For example, given the images below, I need a formula in B3 of output that can sum the profit values from 2/1 to 2/6 (34). 例如,给定下面的图像,我需要输出B3中的公式,可以将利润值从2/1加到2/6(34)。
Could anyone point me in the right direction as far as VBA or even some in sheet excel formulas? 任何人都可以指出我在VBA方面的正确方向,甚至是表格excel公式中的一些方向? Appreciate any feedback 感谢任何反馈
You can use MATCH
to find the ID and Dates, and a series in INDEX
's to return the required range toa SUM
您可以使用MATCH
查找ID和日期,并使用INDEX
的系列将所需范围返回到SUM
=SUM( INDEX( Profit, IDRow, FromDateColumn) : INDEX( Profit, IDRow, ToDateColumn))
where FromDateColumn
, ToDateColumn
and IDRow
are found with MATCH
使用MATCH
找到FromDateColumn
, ToDateColumn
和IDRow
的地方
=SUM(
INDEX(Profit!$1:$1048576, MATCH($A$3,Profit!$A:$A,0), MATCH($B$1,Profit!$1:$1,0)) :
INDEX(Profit!$1:$1048576, MATCH($A$3,Profit!$A:$A,0), MATCH($D$1,Profit!$1:$1,0)) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.