+ Reply to Thread
Results 1 to 15 of 15

Remove spaces in data copied from Excel

  1. #1
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Remove spaces in data copied from Excel

    I have to copy certain columns from an Excel sheet and paste it in a Word table.

    That's a doddle, but for some reason after I've pasted the columns all the values have a number of spaces in front of them.

    How do I prevent this from happening. Deleting the multiple spaces is easy, but the last one is not so easy. Please note that I am forced to use spaces as the thousands separator, so I cannot delete all the spaces!
    Last edited by antonf; 11-25-2009 at 07:49 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Remove spaces in data copied from Excel

    Hi,

    Have you tried the =TRIM() function to remove preceding or trailing spaces?

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: Remove spaces in data copied from Excel

    Excuse my ignorance, but how do I get to use an Excel function in Word?

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Remove spaces in data copied from Excel

    Try next
    1 Open your document\
    2 Press Ctrl+H
    3 Click More > Special > White Space
    4 Leave "Replace with" field bland or type there smth.
    5 Press Replace All button

    HTH
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  5. #5
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: Remove spaces in data copied from Excel

    Thanks HTH, it works fine but then deletes the separator between the thousands as well.

    I gave up on the issue - selected the table and selected and replaced all "double spaces" with single spaces, which left me with preceding spaces as well. Juggling with the column widths assisted in "hiding" the impact of those spaces.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Remove spaces in data copied from Excel

    Hi,

    I had assumed that the spaces were present in the Excel sheet and copied over, hence the advice to get rid of them with the =TRIM() before copying and pasting.

    Rgds

  7. #7
    Registered User
    Join Date
    04-07-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Remove spaces in data copied from Excel

    Experienced the same problem. These extra spaces are annoying!!!!!

    Solution
    My solution was to change the cell formatting to something simple like "Number" and not a custom like "_-* #,##0_-;-* #,##0_-;_-* "-"??_-;_-@_-".

    This has worked for me... so good luck!

  8. #8
    Registered User
    Join Date
    05-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Remove spaces in data copied from Excel

    Thanks artthai, I have frequently encountered this problem when preparing PowerPoint presentations, and I do like to be able to modify the charts within PowerPoint rather than paste objects into PowerPoint. I do use custom number formats all of the time, and I didn't realise that this could be the trigger to my problem with spaces appearing before numbers when being pasted into PowerPoint. Changing the number format to "number" as you suggested worked fist time, which was a rather nice feeling!
    Thanks.

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Remove spaces in data copied from Excel

    In word you can use the Search and Replace. In the Replace field enter this " {2,15}" don't enter the " marks so what you enter is a space, curly brackets, 2 comma 15. This will search for at least 2 spaces together up to 15 spaces together.

    Leave the Replace With field empty.

    Select WILD CARDS then replace all.

    If you want to restrict the Search and Replace to a certain area of text, select that text first then do the Search and Replace.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  10. #10
    Forum Contributor
    Join Date
    01-08-2013
    Location
    ankara
    MS-Off Ver
    Excel 2010
    Posts
    134

    Re: Remove spaces in data copied from Excel

    What does wild cards do?

  11. #11
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Remove spaces in data copied from Excel

    The wild cards allow the search and replace to accept multiple items in the find. In this case, it will find 2 spaces together up to 15 spaces together.

  12. #12
    Forum Contributor
    Join Date
    01-08-2013
    Location
    ankara
    MS-Off Ver
    Excel 2010
    Posts
    134

    Re: Remove spaces in data copied from Excel

    Ty for explanation.

    Also if you want to delete zeros in such a case (for example: " 178 000 000") you can replace " 0" by "#" and then remove all spaces and then put normal spaces back by replacing "#" with " 0". Little tricks depend on situations.

  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Remove spaces in data copied from Excel

    The use of the wild card instead of using a substitution allows you to target 2 to 15 spaces for replacement while leaving single spaces between words untouched.

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Remove spaces in data copied from Excel

    1tane1,

    For future reference, please do not hijack other users' posts. Instead, create your own thread and you can link back to this one.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  15. #15
    Registered User
    Join Date
    02-23-2014
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2007
    Posts
    1

    Post Re: Remove spaces in data copied from Excel

    What I did is simply copied the exact spaces and use the function Find and Replace

    Paste the copied spaces in the Find What: field and leave blank in the Replace With: field.

    Select all content in my word document and press Replace All button. It will rectified for you.

    Regards
    Syahril
    Malaysia

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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