Add hyphens

G

Guest

Hello,
I have a lot of CAS#s, which come in two formats. One as nine digit
numbers, one with hyphens. I'd like to convert the nine digit numbers to
ones with hyphens. Hyphenated version would lob off the leading zeros and
add hyphens at the third and first from the right. Examples are as such:

000050000 to become 50-00-0
001234567 to become 1234-56-7
123456789 to become 123456-78-9
000123456 to become 123-45-6

How can I convert these numbers that are in a table?

Thanks for your help,
Ellen
 
G

Guest

Try this:

[NewValue] = (CAS \ 1000) & "-" & Format(((CAS Mod 1000) \ 10), "00") & "-"
& (CAS Mod 10)

Where:
- CAS is the field with your CAS#


Take care
Mauricio Silva
 
G

Guest

Thanks, John!!!!

Ellen

John Spencer (MVP) said:
This should work for you

Format(Val([Cas]),"#-##-#")
Hello,
I have a lot of CAS#s, which come in two formats. One as nine digit
numbers, one with hyphens. I'd like to convert the nine digit numbers to
ones with hyphens. Hyphenated version would lob off the leading zeros and
add hyphens at the third and first from the right. Examples are as such:

000050000 to become 50-00-0
001234567 to become 1234-56-7
123456789 to become 123456-78-9
000123456 to become 123-45-6

How can I convert these numbers that are in a table?

Thanks for your help,
Ellen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top