Yes, you should able to use OFFSET to derive both ranges in the SUMIF formula based on the value in B4, i.e.
=SUMIF(OFFSET(Sheet2!D$7,MATCH($B$4,Sheet2!$C$7:$C$2000,0),0,20),$A14,OFFSET(Sheet2!E$7, MATCH($B$4,Sheet2!$C$7:$C$2000,0),0,20))
where A14 contains the city
Bookmarks