Praise be to Allah.
Giving charity on behalf of the deceased will benefit him, and the reward thereof will reach him, according to the consensus of the Muslims.
This has been explained previously in the answer to question no. 42384 .
Similarly, the giver will also attain reward for this charity.
This is indicated by the report which Imam Muslim narrated in his Saheeh (1004) from ‘Aa’ishah (may Allah be pleased with her): A man said to the Prophet (blessings and peace of Allah be upon him): My mother died suddenly, and I think that if she had been able to speak, she would have given charity. Will I be rewarded if I give charity on her behalf? He said: “Yes.”
An-Nawawi (may Allah have mercy on him) said: This hadith indicates that it is permissible and is recommended to give charity on behalf of the deceased, and that the reward thereof will reach him and benefit him, and it will also benefit the giver. There is consensus among the Muslims on all of that." (Sharh Saheeh Muslim 11/84).
Shaykh Ibn Baaz (may Allah have mercy on him) said: Charity will benefit the deceased, and there is the hope that the giver will have a reward like that which will reach the deceased, because he is doing a good deed, so there is the hope that he will a reward like that of what he gave. The Prophet (blessings and peace of Allah be upon him) said: “The one who guides others to something good will have a reward like that of the one who does it.” If the believer urges people to something good, or does something good on behalf of others, there is the hope that he will have a similar reward. So if he gives charity on behalf of his father or his mother, and the like, then the one on whose behalf charity is given will have a reward, and the giver will also have reward.
Similarly, if he does Hajj on behalf of his father or his mother, he will have reward, and his father and mother will also have reward, and there is the hope that his reward will be like theirs, or even greater, because of his good deed, upholding ties of kinship and honouring his parents. There are many similar examples, for the grace of Allah is immense.
The Islamic principle regarding such matters is that the one who does good to benefit others will have a great reward, and if he does a good deed on behalf of someone else, there is the hope that he will have a reward similar to that which the person on whose behalf that good deed was done will have." (Fataawa Noor ‘ala ad-Darb 14/313).
And Allah knows best.