For those of you with old change gear lathes such as South Bend or Logan, metric threads can be a challenge. The numerically correct gears are 127 and 100 and are ridiculously expensive.
It is possible to take your collection of gears and break each in to its factors and try to work out ratios closest to the ratio of the lead screw thread and 25.4. It's doable but a real PITA.
Here's a program which, although not very user friendly, actually works. Download it, unzip it, open the text file and insert the metric lead screw thread (generally 8tpi), drive gear, then list every gear you have.
It will give you the best gear ratios for any given metric thread and the error from the mathematically correct thread.