View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
smartgal smartgal is offline
external usenet poster
 
Posts: 84
Default Formatting for credit card number input

I have a few issues...
I tried a the following formulas:
Amex:
=LEFT(A1,4)&"-"&MID(A1,5,6)&"-"&RIGHT(A1,5)
MC / Visa:
=LEFT(A1,4)&"-"&MID(A1,5,4)&"-"&MID(A1,9,4)&"-"&RIGHT(A1,4)

Not only does the Amex formatting not carry over, but it drops off the last
character and adds a "0" to the end of it, on both Amex and MC/Visa.

Also, in the formula, is 'a1' a cell that should be formatted for visa/mc
or amex?
They are to enter the type of card from a drop down menu in cell 'b12' and
enter the cc number in its entirey in to cell 'b13'. I am not sure if they
need to be incorporated. (I did a vlookup with the formulas in a hidden row
with the proper label, so that is how it pulls it over. )

Thank you!!



"Fred Smith" wrote:

Excel's maximum precision is 15 digits. So to handle 16 digits, you need to
use text, not numbers. Therefore formatting will not help you.

You can format with a formula something like this:
=if(however you tell Visa vs Amex,left(a1,4)&" - "&mid(a1,5,4)&" -
"&mid(a1,9,4)&" - "&right(a1,4),left(a1,4)&"-"&mid(a1,5,6)&"-"&right(a1,5))

Regards,
Fred

"smartgal" wrote in message
...
I have a cell in which the user will input a credit card number and I want
it
to display a format based on the type of card. So Visa / MC should be
"####
- #### - #### - ####" but Amex should be "####-######-#####" - the user
will
choose the type of card in another cell so what's the most effective way
to
conditionally format the input to display properly based on the card type?


.