1. Andy has lived for 40 years.

2. The animal has existed for 7 years.
(Are the sentences grammatical?)

Yes, both are grammatical. 1 is used more than 2.