简体   繁体   English

如何在Excel / VBA中以标题行作为条件的行中查找vlookup?

[英]How can I vlookup across rows with title rows as criteria in Excel/VBA?

Example

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找到FromDateColumnToDateColumnIDRow的地方

=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.

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