The AG is estimated to be approximately 2.3 million light years away -- one light year being the *distance* light travels in a year at its constant speed of 186,000 miles per second. It works out to about 5.9 trillion(with a T) miles.
They believe Andromeda will "mingle" with our Milky Way galaxy in about 4 or 5 billion years. That's about the same time when our Sun should be in the process of destroying itself by moving to the Red Giant stage. This will happen when the Sun uses up much of the material it needs to continue nuclear processes. Without that outward push from nuclear reactions gravity will win out and cause an implosion. The implosion, in turn, will ultimately result in a "rebounding" which will cause the Sun to grow to an enormous size and eventually engulf all planets up to Mars.
Red Giant Phase:
In 5 billion years from now, the Sun will enter what is known as the Red Giant phase of its evolution. This will begin once all hydrogen is exhausted in the core and the inert helium ash that has built up there becomes unstable and collapses under its own weight. This will cause the core to heat up and get denser, causing the Sun to grow in size.
It is calculated that the expanding Sun will grow large enough to encompass the orbits of Mercury, Venus, and maybe even Earth. Even if the Earth were to survive being consumed, its new proximity to the the intense heat of this red sun would scorch our planet and make it completely impossible for life to survive. However, astronomers have noted that as the Sun expands, the orbit of the planets is likely to change as well.
When the Sun reaches this late stage in its stellar evolution, it will lose a tremendous amount of mass through powerful stellar winds. Basically, as it grows, it loses mass, causing the planets to spiral outwards. So the question is, will the expanding Sun overtake the planets spiraling outwards, or will Earth (and maybe even Venus) escape its grasp? ...”
https://www.universetoday.com/12648/will-earth-survive-when-the-sun-becomes-a-red-giant/