View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Formatting for credit card number input

You are not going to have a whole pile of luck with this one... XL (and your
computer in general) can only handle 15 significant digits. A credit card
number is 16 digits long. That means that it can not hold the las digit if
your cell is a number. That leaves us with Text which will hold 16 digits but
since it is not a number you can not format it using regular formatting. You
will need to use formulas to break the text apart and add the hyphens...

=left(A1, 4) & "-" & Mid(A1, 5, 6) & "-" & Mid(A1, 10, 6)

Use an if formula to determine if you have Visa or MC...
--
HTH...

Jim Thomlinson


"smartgal" wrote:

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?