If we have a preposition before the relative pronoun, things start to get more difficult.
First, the relative pronoun is cannot be anymore the subject of the subordinate clause. Then, qui can be used, but only under certain conditions.
1) Qui can only refer to persons, if used with a preposition.
2) Qui can only be used with certain prepositions.
When having a preposition with the relative pronoun, lequel / laquelle / lesquels / lesquelles is mostly used.
à + qui
L' homme à qui j' ai donné l' argent a disparu.
L' homme auquel j' ai donné l' argent a disparu.
The man, to whom I have given money, has disappeared.
La femme à qui j' ai donné l' argent a disparu.
La femme à laquelle j' ai donné l' argent a disparu.
The woman, to whom I have given money, has disappeared.
de + qui (more usual: dont, also possible: duquel)*
L' homme de qui nous avons parlé est médecin.
L' homme dont nous avons parlé est médecin.
The man about whom we have talked is a doctor.
avec + qui
L' homme avec qui nous sommes allés en Espagne habite à Paris.
L' homme avec lequel nous sommes allés en Espagne habite à Paris.
The man with whom we have gone to Spain, lives in Paris.
sans + qui
C' est l' homme sans qui rien ne marche.
C' est l' homme sans lequel rien ne marche.
This is the man, without whom nothing works.
* Here we have the case that there are three possibilities competing: de qui, duquel, dont. Later on, we will go more into details regarding this.
As we have already mentioned, some prepositions cannot be used with qui. These are entre
and parmi. Afther these prepositions lequel
/ laquelles / lesquels / lesquelles must be used.
Il y avait beaucoup de fameuses personnes parmi lesquelles des actrices connues.
There were many famous people, among which well known actresses.
On a reconnu tous les voleurs parmi lesquels aussi Al Capone.
All thieves were recognised, among which was also Al Capone.
Voilà trois vins parmi lesquels tu peux choisir.
Here are three wines, among which you can choose.
So far we have discussed the case that the referred object is a person. When the referred object is a non-living thing, always lequel
/ laquelle / lesquels / lesquelles is used.
La chaise sur laquelle il s' est assis, s' est effondrée.
The chair, on which he has seated himself, is broken down.
To make a long story short: when who, whom or whose can be used with prepositions, also qui can be used. When we rather use which in English with the preposition, in French we use Lequel / laquelle / lesquels / lesquelles. Or, to make it eaven shorter: with prepositions it is always possible to use lequel / laquelle / lesquels / lesquelles.