All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The Prophet said: "My nation is forgiven and it will not be punished in the Hereafter. Its punishment is in this world: [it is befallen by] afflictions, earthquakes and killing." [Ahmad and Abu Daawood] This is of course in general.
Al-Mullaa said: "Most of their punishment is taken away in this world by the hardship, difficulties, diseases, and other afflictions that befall them."
So the hardships wipe out the sins of a person although he might have caused them himself.
However, this does not contradict the texts and narrations which state that some people of this nation will be punished in Hellfire on the Day of Judgment for some sins which they have committed [in this world].
Allaah Knows best.