Take the he/him test. For example, as the question using either who or whom, if the answer is he, then you'll want to use "who" if the answer is him, you'll want to use "whom". Who will go to the market? He will. Who is it for? It's for him--you'll need you use whom to form this question. (Whom is it for).