He was asked:
“A Muslim man performs a deed that merits having a palace built for him in Paradise and plantings made in his name. He then commits sins for which he deserves Hell. If he enters Hell, how can he be listed as being in Paradise while he is in Hell?”
He replied:
If he sincerely repents of his sins, Allah will forgive him and will not deprive him of what He had promised him; rather, He will grant it to him. If he does not repent, his good and evil deeds will be weighed. If his good deeds outweigh his evil deeds, he will be among those rewarded; if his evil deeds outweigh his good deeds, he will be among those punished.
The reward prepared for him is then nullified by the evil deeds that outweighed his good deeds. Likewise, if he commits evil deeds for which he deserves Hell, then afterwards performs good deeds, those evil deeds are erased. And Allah knows best.