Hello
Try the following formula in cell F5:

=IF(AND('2012_V'!L11=165,'2012_V'!N11=1),MAX('2012_V'!$D$11:$D$27)-AF5,"")

I had to convert your numbers from text to numbers in columns L and N on the 2012_V sheet to get this to work. Is there any reason why they were formatted as text?

Hope this helps