how to remove spaces in a cell/column

G

George Nicholson

Do you need something other than the SUBSTITUTE (and/or REPLACE) functions?
 
G

Guest

Here is VBA code from David McRitchie that works for me. Copy starting with
Sub,open your spreadsheet, right click on the tab at the bottom, select View
Code, paste the VBA code, and close out of VBA (file, close and return..).
Highlight the columns that need the spaces removed, go to Tools, Macro,
Macros, Run and select the RemoveAllSpaces, and select Run. That should do
it!!

Good luck!
Carole O

Sub RemoveAllSpaces()
'David McRitchie 2000-10-24
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Selection.SpecialCells(xlConstants).Replace What:=Chr(160), _
Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=True
Selection.SpecialCells(xlConstants).Replace What:=Chr(32), _
Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
W

wjohnson

Select your Column or Columns:
Go To EDIT - REPLACE - in the FIND - press the space bar 1 time.
Leave the REPLACE blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top