+ Reply to Thread
Results 1 to 6 of 6

Removing spaces from credit card numbers

  1. #1
    Registered User
    Join Date
    04-06-2016
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    13

    Post Removing spaces from credit card numbers

    Hi all, basic excel user here. I need to copy and paste credit card numbers from an excel sheet into a processor. The processor needs the spaces removed, however I can't find a way to easily remove all spaces from the numbers (entered as 1234 1234 1234 1234).

    All formatting changes I've made the numbers to something else by either completely changing them (5.160777E+15) or rounding the last digit. I was intending to change the numbers to text formatting and then ctrl+f and replace spaces with nothing.

    A quick search online has only confused me further. Can anyone please provide some insight or some step-by-step on how to achieve this and/or how to prevent this issue in the future (for example if we entered the credit card info into a cell formatted a specific way from the get-go).

    Thank you! Pulling my hair out here!

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Removing spaces from credit card numbers

    Try SUBSTITUTE function
    Enter in B1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B
    1 1234 1234 1234 1234 1234123412341234
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,505

    Re: Removing spaces from credit card numbers

    this would work if you don't just want to use find " " and replace (left blank)
    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1," ","")," ","")," ","")
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Removing spaces from credit card numbers

    You can do it via macro, but a quick way would be to use a helper column and then insert this formula and drag down as needed:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The above will remove the spaces. Now how the helper column works.
    1. Before copying, on the worksheet that has the credit card number (with spaces), insert a column somewhere where it is not in your way
    2. Insert the formula above and refer to the column that has the card numbers
    3. Copy the contents of the column that has the trimmed credit card numbers
    4. Paste as values in your destination sheet for your processor.

    Edit: Alkey beat me to it. He and I are suggesting the same.
    Last edited by ron2k_1; 04-27-2018 at 02:34 PM.
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  5. #5
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,505

    Re: Removing spaces from credit card numbers

    I didn't think to go with the shorter version but I see AlKey's is better.

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Removing spaces from credit card numbers

    .
    And ... if you don't want to drag a formula down the sheet (maybe you have 15,000 rows of card #'s ?), paste this macro into a Routine Module, place a command button on the sheet of card numbers, highlight all the numbers then click the button.

    Please Login or Register  to view this content.
    Sample workbook attached
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. removing spaces between the numbers
    By martin in forum Excel General
    Replies: 8
    Last Post: 06-28-2014, 03:55 AM
  2. [SOLVED] Credit card type based on card number
    By wlsnoops in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-26-2013, 10:25 AM
  3. [SOLVED] Why would code to format credit card numbers stopped working.
    By mjbsutton in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-18-2012, 01:23 PM
  4. Removing spaces after numbers
    By Proto1Star in forum Excel General
    Replies: 20
    Last Post: 03-04-2012, 02:52 PM
  5. Credit Card Calculator
    By Juan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2006, 09:50 PM
  6. why does excel change last digit of credit card numbers to zero?
    By dacton in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-07-2005, 05:10 PM
  7. Format for credit card numbers
    By Schmacker in forum Excel General
    Replies: 3
    Last Post: 10-12-2005, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1