Yatta (やった) means “I did it!” or “Yes!”: a shout of joy when something goes your way.
The last shot goes in, the results board lights up, the envelope opens — やったー! Arms in the air. It is one of the happiest words in anime, and real people shout it just the same.
What it actually means
やった is the casual past form of やる, a casual word for “do” that means much the same as する. Literally it is “did”. As a cheer it means “I did it!” — or, just as often, “Yes! Great!” when good luck simply happens to you.
やったね and やりました
Add ね and it turns toward someone else: やったね! means “you did it!” or “way to go!”. The polite version, やりました, is what you hear from athletes in interviews: “I did it.”

テスト、 ひゃくてんでした!
I got 100 on the test!

やったね! すごい!
You did it! Amazing!
Can you use it?
Yes — whenever you are truly happy about something. It is casual, so in a formal speech you would say よかったです (“I'm glad”) instead. But nobody minds a やった! when good news arrives.