Remove punctuation mark '

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?
 
P

Patrick Molloy

could you try
=MID(A1,2,LEN(A1) )

as the first chracter may not be a ' even though it appears to be.
 
P

Patrick Molloy

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

use =MID(A1,1,LEN(A1) )
 
G

Gary''s Student

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
 
R

Rick Rothstein

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
 
R

Rick Rothstein

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
 
S

Sal

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) )
 
S

Sal

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
 
S

Sal

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.
 

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