An easy approximation is that 1 km/s for 1 million years is about 1 parsec.
Andromeda Nebula is approaching Sun at a speed of 301 km/s, and that value is known with the precision of +- 1 km/s.
Andromeda Nebula is at a distance of 778 kpc, known with +- 17 kpc.
At that speed, Sun should arrive in 2,6 milliard years.
But the thing is, this is the radial velocity relative to Sun.
Sun is orbiting Milky Way.
Milky Way happens to have rotation plane near Andromeda Nebula.
And Sun happens to be orbiting Milky Way in direction closely approaching Andromeda Nebula.
The orbital speed of Sun around Milky Way is less well known. It turns out that the radial approach speed of Milky Way and Andromeda, as of now, is 109 km/s - with errors +- 4 km/s.
In 100 million years, Sun will have completed half an orbit around Milky Way, and Andromeda Nebula shall be receding at 100 km/h.
Note that within 2,5 million years, the curve of Sun´s orbit will have little effect yet... so the Sun will have approached Andromeda by about 800 pc or 2500 lightyears.
If the mass of Milky Way and Andromeda were negligibly small, then Milky Way and Andromeda should take 7 milliard years to collide - unless they possesses transverse velocity and miss each other.
But the masses are highly unknown. Therefore it is unknown how much Milky Way and Andromeda would accelerate on approach, and when they would have a collision or closest pass.