Distance between 2 cities

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Hi Can you give me a quote for a vba code that will calculate the mile or kilometers driven in each state passed through? For example, if traveling from Detroit, MI to St. Louis, MO =
IN=248.17 …

Not able to crack this code on my own.
WIll be thank full if you help me out on this.

Kshitij Yadav


Hi Kshitij,
the feasibility of this task is not as easy as it seems and will depend on your source data e.g.
– If your data consists of all necessary waypoints on the boundaries of states then this should be feasible enough,
– If your data just consists of a start and end location through multiple states then the situation is MUCH more complicated. This is because you would need to identify all interim waypoints on the boundaries of states. You would probably need to use the Google Maps Directions API. Even then however this won’t be very precise as the waypoints won’t be provided ideally on the borders of states.

Therefore the first question you need to answer is what is the problem you are trying to solve?

Simply the best place to learn Excel VBA