简体   繁体   中英

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.

On sheet 1, I want to specify a date range in sheet 1 cells B1 & D1 for which profit margin would be calculated. 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).

Could anyone point me in the right direction as far as VBA or even some in sheet excel formulas? 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

=SUM( INDEX( Profit, IDRow, FromDateColumn) : INDEX( Profit, IDRow, ToDateColumn))

where FromDateColumn , ToDateColumn and IDRow are found with MATCH

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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