Hello Excellearner, for your second attachment you need to fix row 16 so that when you copy the formula down that row doesn't change.
I'd prefer to use INDEX rather than OFFSET to find the sum range, i.e. with this version of cyberkiwi's suggestion in I34 copied down and across
=SUMPRODUCT(INDEX('data sheet'!$F$18:$BW$32,MATCH($B34,'data sheet'!$B$18:$B$32,0),0),--('data sheet'!$F$16:$BW$16>=I$26),--('data sheet'!$F$16:$BW$16<=I$30))
Note that works by finding the relevant row between 18 and 32 based on the value in B34. If there are multiple rows where the variable matches then you can use this version
=SUMPRODUCT(($B34='data sheet'!$B$18:$B$32)*('data sheet'!$F$16:$BW$16>=I$26)*('data sheet'!$F$16:$BW$16<=I$30),'data sheet'!$F$18:$BW$32)
Although shorter the latter formula is probably less efficient so I'd recommend the first one unless you have multiple rows to sum
regards, barry