Credit Card Verification

G

Guest

Guest
Hi all,
I have an interesting one... am looking for a way to verify a credit card number using the check digit (there's standard formula). I saw the source code on the net but its in C. Just wondering does anyone have it in vba. Thanks.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If the code in C is short, slap it in here and maybe a kind person code convert it to VB.
 
Upvote 0
Hi,

for a non-VBA approach, try this cumbersome formula :

assuming A1 houses your credit card number :

=IF(MOD(SUM(IF((MID(TEXT(+A1,"00000000000000000000"),{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20},1)*({2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1}))<10,(MID(TEXT(+A1,"00000000000000000000"),{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20},1)*({2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1})),MID((MID(TEXT(+A1,"00000000000000000000"),{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20},1)*({2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1})),1,1)+MID((MID(TEXT(+A1,"00000000000000000000"),{1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20},1)*({2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1;2;1})),2,1))),10)=0,"Okay","Not valid")

I'm sure it could be shortened *slightly*, but it seems to work on my credit card numbers (first 15 digits). It looks at the number for validity rather than the check digit, so not exactly what you asked for, but it might help.
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,667
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top