Using Credit Card Numbers in Excel
James asks in Custom Cell Formatting in Excel Post,
I have a problem when formatting a cell that has 16 or more digits … We are working with Credit Card numbers and want to be able to enter them as a 16 digit number like this: 1234123412341234 but want them to look like this: 1234 1234 1234 1234
The problem we’re having is that the last digit always turns into a 0 (zero) and the number ends up looking like this: 1234 1234 1234 1230 The custom format type we created is: 0000 0000 0000 0000 but we’ve also tried: #### #### #### #### with the same results.
This only happens when using 16 or more digits. If we use 15 or less digits, the Custom format works fine. Unfortunately, credit cards have 16 digits so we’re stuck with the problem.
We’ve tried this on Excel 2007 with service pack 1 and on Excel 2000 with service pack 3 with the same results. The Operating Systems we’ve tried it on are Windows XP with Service Pack 3 (and all other Microsoft Updates installed) and on Windows 2000 with Service Pack 4.
Well, this is because Excel stores numbers with precision of 15 digits. So anything more and it is automatically converted in to engineering format.
Here is a simple workaround if you need to store and work with credit card numbers in excel:
Change the cell format to TEXT from general or number. Thus excel treats numbers as text and you can escape the truncation.
But what if you need to format the credit card numbers in a special way? well, we use a knife and cut the number in to 4 small parts. Not really, we use the LEFT, MID and RIGHT formulas to process the credit card number and format it the way we want.
For eg. if you want to format the credit card number 1234123412341234 like 1234 1234 1234 1234, you can use the formula
=LEFT(B3,4)&" "&MID(B3,5,4)&" "&MID(B3,9,4)&" "&RIGHT(B3,4)
and if you want to test the credit card, you know where to go. To our Excel formula E-book page.
Leave a Reply
|Budget vs. Actual Charts – 14 Charting Ideas You can Use||There is an Easter Egg in this Post|