Removing Spaces In Cell

Ethanflux

New Member
Joined
May 3, 2013
Messages
11
I have some information provided to me in cells and for some reason they provide names with like 9 or 10 spaces afterwards. How can I select that column and remove those spaces?
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
Ctrl+H (Find and Replace) space with nothing
 

Firefly2012

Well-known Member
Joined
Dec 28, 2011
Messages
3,638
If you have no spaces in the cells that you wish to keep (eg between fore and surname) then you could do a Find/Replace on the entire column:

1. Select column
2. Use Ctrl+h to open up Find/Replace dialog
3. In Find box type a space, leave Replace box blank
4. Under options, make sure "Match entire cell contents" is unchecked
5. Hit Replace All

An alternative formula approach might be in adjacent cells to use TRIM:

=TRIM(A1)

and copy down. You could then do a copy/pastespecial>values over your originals

Last alternative I will mention is to select the column, open up the VBE with Alt+F11 and open up the Immediate Window with Ctrl+g and then type (or copy) in the following and place all on one line and press Enter at the end of the line:

Code:
For Each c In Selection:c.Value = Application.Trim(c.Value):Next
 

Watch MrExcel Video

Forum statistics

Threads
1,122,207
Messages
5,594,843
Members
413,944
Latest member
3xc3ln00b

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
Top