Google Sheets Formatting – How to Format Credit Card Numbers as Four Digit Blocks

formattinggoogle sheets

I have this credit card number in a Google Sheets of the following format:

XXXXXXXXXXXXXXXX

How can I make it display like XXXX XXXX XXXX XXXX or XXXX-XXXX-XXXX-XXXX where they're in four digit blocks?

Best Answer

With dashes (-):

=CONCATENATE(LEFT(A1,4)&"-"&MID(A1,5,4)&"-"&MID(A1,9,4)&"-"&RIGHT(A1,4))

or with spaces ():

=CONCATENATE(LEFT(A1,4)&" "&MID(A1,5,4)&" "&MID(A1,9,4)&" "&RIGHT(A1,4))