PDA

View Full Version : Solved: Delete dash with space



parscon
05-10-2012, 07:33 AM
i have a data that all the cell have - (dash with space that mean after dash have a 1 space)

i have this code for delete this dash but it is not work .and this dash will be in right with 1 space .

Please help me


Sub Trim()
For Each c In Worksheets("Sheet1").Range("A1:A3").Cells
If Right(c.Value, 1) = "- " Then
c.Value = Mid(c.Value, 1, Len(c) - 1)
End If
Next
End Sub



example : 2322424-

Bob Phillips
05-10-2012, 07:37 AM
Sub Trim()
For Each c In Worksheets("Sheet1").Range("A1:A3")
If Right(c.Value, 2) = "- " Then
c.Value = Left(c.Value, Len(c.Value) - 2)
End If
Next
End Sub

parscon
05-10-2012, 07:40 AM
Thank you for your help