I want to output the `professor` field based on the input in the yellow fields. The input will be the possible `sub_code` of `column D` OR `column G`. I've tried `VLOOKUP(...)` and `INDEX(...,MATCH(...))`, but I get stuck when trying to perform: `either column D or column G`. 

For example, I want `John` to be printed in E7 when I type `Ag1` or `Ps1` in E8.

How could I write a function for this case? 

[![Spreadsheet table](https://i.stack.imgur.com/Pb9Qx.png)](https://i.stack.imgur.com/Pb9Qx.png)