Quote Originally Posted by mperrah View Post
So to verify what your function reads to me:
look up D9 in range c9 to y11
and display a cell 22 spaces to the right if a match is found
else
display either j9-x9 if j9 is bigger
or 0 if x9 is bigger

if I am on the right track I would put the if at the beggining

if (j9 > agency_contract!x9, vlookup(d9, Agency_contract!c9:y11,22,j9-agency_contract!x9), 0)
not tested I'm away from my pc, but looks like it might be closer
i tried that but all that does is return the value of Agency_Contract X9 which is either 8 or 0