The text below is from wikipedia, I wasn't able to convert that into a macro so I am hoping to get some help.
What I want to be able to do is paste in a list of 8 digit cusips into a column, and then have a macro/formula that will generate the 9th digit and place that digit in the column next to it.
Description
The first six characters are known as the base (or CUSIP-6), and uniquely identify the issuer. Issuer codes are assigned alphabetically from a series that includes deliberate built-in "gaps" for future expansion. The 7th and 8th digit identify the exact issue. The 9th digit is an automatically generated checksum (some clearing bodies ignore or truncate the last digit). The last three characters of the issuer code can be letters, in order to provide more room for expansion.
Issuer numbers 990 to 999 and 99A to 99Z in each group of 1,000 numbers are reserved for internal use. This permits a user to assign an issuer number to any issuer which might be relevant to his holdings but which does not qualify for coverage under the CUSIP numbering system. Other issuer numbers (990000 to 999999 and 99000A to 99999Z) are also reserved for the user so that they may be assigned to non-security assets or to number miscellaneous internal assets.
The 7th and 8th digit identify the exact issue, the format being dependent on the type of security. In general, numbers are used for equities and letters are used for fixed income. For commercial paper the first issue character is generated by taking the letter code of the maturity month, the second issue character is the day of the maturity date, with letters used for numbers over 9. The first security issued by any particular issuer is numbered "10". Newer issues are numbered by adding ten to the last used number up to 80, at which point the next issue is "88" and then goes down by tens. The issue number "01" is used to label all options on equities from that issuer.
Fixed income issues are labeled using a similar fashion, but due to there being so many of them they use letters instead of digits. The first issue is labeled "AA", the next "A2", then "2A" and onto "A3". To avoid confusion, the letters I and O are not used since they might be mistaken for the digits 1 and 0.
The 9th digit is an automatically generated check digit using the "Modulus 10 Double Add Double" technique.[2] To calculate the check digit every second digit is multiplied by two. Letters are converted to numbers based on their ordinal position in the alphabet.
[edit]Check digit pseudocode
algorithm Cusip-Check-Digit(cusip) is
Input: an 8-character CUSIP
Output: the check digit for that CUSIP
sum := 0
for 1 ≤ i ≤ 8 do
c := the ith character of cusip
if c is a digit then
v := numeric value of the digit c
else if c is a letter then
p := ordinal position of c in the alphabet (A=1, B=2...)
v := p + 9
else if c = "*" then
v := 36
else if c = "@" then
v := 37
else if c = "#" then
v := 38
end if
if i is even then
v := v × 2
end if
sum := sum + v div 10 + v mod 10
repeat
return (10 - (sum mod 10)) mod 10
end function
What I want to be able to do is paste in a list of 8 digit cusips into a column, and then have a macro/formula that will generate the 9th digit and place that digit in the column next to it.
Description
The first six characters are known as the base (or CUSIP-6), and uniquely identify the issuer. Issuer codes are assigned alphabetically from a series that includes deliberate built-in "gaps" for future expansion. The 7th and 8th digit identify the exact issue. The 9th digit is an automatically generated checksum (some clearing bodies ignore or truncate the last digit). The last three characters of the issuer code can be letters, in order to provide more room for expansion.
Issuer numbers 990 to 999 and 99A to 99Z in each group of 1,000 numbers are reserved for internal use. This permits a user to assign an issuer number to any issuer which might be relevant to his holdings but which does not qualify for coverage under the CUSIP numbering system. Other issuer numbers (990000 to 999999 and 99000A to 99999Z) are also reserved for the user so that they may be assigned to non-security assets or to number miscellaneous internal assets.
The 7th and 8th digit identify the exact issue, the format being dependent on the type of security. In general, numbers are used for equities and letters are used for fixed income. For commercial paper the first issue character is generated by taking the letter code of the maturity month, the second issue character is the day of the maturity date, with letters used for numbers over 9. The first security issued by any particular issuer is numbered "10". Newer issues are numbered by adding ten to the last used number up to 80, at which point the next issue is "88" and then goes down by tens. The issue number "01" is used to label all options on equities from that issuer.
Fixed income issues are labeled using a similar fashion, but due to there being so many of them they use letters instead of digits. The first issue is labeled "AA", the next "A2", then "2A" and onto "A3". To avoid confusion, the letters I and O are not used since they might be mistaken for the digits 1 and 0.
The 9th digit is an automatically generated check digit using the "Modulus 10 Double Add Double" technique.[2] To calculate the check digit every second digit is multiplied by two. Letters are converted to numbers based on their ordinal position in the alphabet.
[edit]Check digit pseudocode
algorithm Cusip-Check-Digit(cusip) is
Input: an 8-character CUSIP
Output: the check digit for that CUSIP
sum := 0
for 1 ≤ i ≤ 8 do
c := the ith character of cusip
if c is a digit then
v := numeric value of the digit c
else if c is a letter then
p := ordinal position of c in the alphabet (A=1, B=2...)
v := p + 9
else if c = "*" then
v := 36
else if c = "@" then
v := 37
else if c = "#" then
v := 38
end if
if i is even then
v := v × 2
end if
sum := sum + v div 10 + v mod 10
repeat
return (10 - (sum mod 10)) mod 10
end function