There are differing degrees of discipline in the Church, excommunication being the worst. Even an excommunicated Catholic may attend Mass, in fact it is recommended, in order that at some point the excommunicated person recognizes his/her mistakes, repents and returns.
One of the misunderstood things about excommunication (especially thanks to the mainstream media) is that excommunication is really an act of mercy. If you are receiving the sacraments in a state of mortal sin you are committing sacrilege; excommunication prevents you from digging your hole deeper, so to speak.
If yours is a private sin, and you were excommunicated discreetly, your return will be just as discreet. If your sin is very public, such as defying Church law publicly (as so many of our politicians do), and you were publicly excommunicated (as in being announced in the papers, or a public announcement was made by the Church), your repentance and return (it used to be that way anyway, not 100% sure now) needs to be public, so that no one is scandalized by seeing you receive the sacraments without knowing for sure if you have been reconciled to the Church and her laws, and it’s better that you publicly renounce your sin (but again, this is all according to the particular circumstance of the excommunication).
It is vitally important that you forgive yourself - if you don’t, Satan still has a hold on you. God’s mercy and love is greater than your sin - please don’t commit the sin of Judas and despair, because sin cannot hold a truly repentant soul. Remember that when St Paul complained of the thorn in his side and his weakness, Jesus reminded him that “My grace is sufficient for thee.” This kept St Paul humble - remember that St Paul was just as human as the rest of us, and I’m quite sure that he thought about, from time to time, the things he did. Confessed sin God forgets, but for us to remember the things we’ve done doesn’t mean we haven’t really repented; if we confess them in true sorrow for them we are absolved, but remembering them tends to keep us humble.
Here is a link that describes the different disciplines:
en.wikipedia.org/wiki/Latae_sententiae