When we need a preposition with the relative pronouns which, whom, or whose, the preposition can come before the relative pronoun. This is generally more formal.
I studied with an American professor from whom I learned many fascinating things. = more formal.
I studied with an American professor who I learned many fascinating things from. = less formal.
This is the office in which I worked. = more formal
This is the office which I worked in. = less formal
We cannot use that after prepositions.
After a preposition, who become whom.
Prepositions appear in several noun phrases which contain relative pronouns, e.g.
some of which/whom, many which/whom, most of which/whom, the first/last of which/whom.
They also appear in several adverbial phrases which contain relative pronouns, e.g.
In which case, at which point, for which reason.