I have a working sheet which extract tax code from database column B as lookup and extract tax rate on column E, however when there is a criteria in COLUMN K,then lookup in database corresponding column M and extract the tax amount, if another criteria in column K then look to the corresponding column and extract the tax amount.
Code:
=SUMIF('DATABASE TAX CODE '!B:B,G2,INDEX('DATABASE TAX CODE '!$B$1:$R$6395,,MATCH(IF($K2="",$AA1,$K2),'DATABASE TAX CODE '!$B$1:$R$1,0)))