you cats are the gonest. two things to keep in mind as you proceed:
1) chain length is not continuous, but rather an integer multiple of link length;
2) the distance between the center of the bottom bracket and the rear hub (what herst refers to as "d") is not constrained to be constant, unless maybe if you have vertical dropouts.
give us a nice little vba script when you're finished!