View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Janis Janis is offline
external usenet poster
 
Posts: 360
Default macro to delete spaces doesn't compile

I got the one with the selection to work for now but for the user I would
like to have the workbook and the column so I tried this and something is
wrong with the object path for C.


Sub cleanText()
Dim C As Range
On Error Resume Next
With ActiveWorkbook
Set C = Worksheets("Port History).Columns(L)
C.Replace What:=", ", Replacement:=",", SearchOrder:=xlByColumns

On Error GoTo 0
End With
End Sub

thanks

"Joel" wrote:

I don't know why you have an intersection, but this code runs

Sub delSpaces()
Set c = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)
c.Replace What:=", ", Replacement:=","

End Sub


"Janis" wrote:

This macro has an error and doesn't compile. I also need it to delete 2
spaces.


Sub delSpaces()

Intersect(Selection, Selection.SpecialCells(xlConstants,
xlTextValues)).replace(", ",",")

End Sub

tia,