Remove punctuation mark '

  • Thread starter Thread starter Sal
  • Start date Start date
S

Sal

This punctuation mark ' appears before every word in every row of column A.
Each row only has one word. I tried removing the punctuation mark ' using
the Replace function from the Edit menu. I put replace what: ( ' ) / replace
with: (blank), but it didn’t work. I also tried other options from the help
menu but they didn’t work out well either.

Is there a code that will remove ' punctuation mark from every cell in
column A that has a word written in it?
 
could you try
=MID(A1,2,LEN(A1) )

as the first chracter may not be a ' even though it appears to be.
 
no to my previious.
' was a LOTUS alignment control, and this meant left align

use =MID(A1,1,LEN(A1) )
 
If you want to remove them in place, select the cells and run:

Sub tickout()
Dim r As Range
For Each r In Selection
If r.PrefixCharacter = "'" Then
r.Value = r.Value
End If
Next
End Sub
 
Here is a non-looping method that I believe also works...

As a one-liner
=========================================
Selection.SpecialCells(xlTextValues Or xlCellTypeConstants).Value = _
Selection.SpecialCells(xlTextValues Or xlCellTypeConstants).Value

Same code "prettied up" for readability
=========================================
With Selection.SpecialCells(xlTextValues Or xlCellTypeConstants)
.Value = .Value
End With
 
I think I used the wrong syntax. I believe my code should have been written
this way...

As a one-liner
=========================================
Selection.SpecialCells(xlCellTypeConstants, xlTextValues).Value = _
Selection.SpecialCells(xlTextValues Or xlCellTypeConstants).Value

Same code "prettied up" for readability
=========================================
With Selection.SpecialCells(xlCellTypeConstants, xlTextValues)
.Value = .Value
End With
 
Thank you again for sharing your input.

Patrick Molloy said:
no to my previious.
' was a LOTUS alignment control, and this meant left align

use =MID(A1,1,LEN(A1) )
 
Nice! Thank you Rick. I appreciate your help.

Rick Rothstein said:
Here is a non-looping method that I believe also works...

As a one-liner
=========================================
Selection.SpecialCells(xlTextValues Or xlCellTypeConstants).Value = _
Selection.SpecialCells(xlTextValues Or xlCellTypeConstants).Value

Same code "prettied up" for readability
=========================================
With Selection.SpecialCells(xlTextValues Or xlCellTypeConstants)
.Value = .Value
End With
 
Thank you for sharing this with me. It is helpful. I am lucky to have been
helped by you as well as the other contributors. Thank you.
 
Back
Top