Thursday, October 30, 2008

Remove apostrophe from excel

Já alguma vez pensaram em como resolver a "Plica" do excel?

Eis uma macro que faz isso :-), emprestada de um outro site e corrigida

Option Explicit
Sub testeme_Click()

Dim myRng As Range
Dim myCell As Range

Set myRng = Nothing
On Error Resume Next
Set myRng = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeConstants))
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No constants in selection!"
Exit Sub
End If

For Each myCell In myRng.Cells
If myCell.PrefixCharacter = "'" Then
myCell.Value = "" & myCell.Text
End If
Next myCell

End Sub


Há muito que não colocava algo aqui, e isto parece-me bem :-)

Adeus cibernautas