Macro to add the " symbol to the beginning and end of cells selected

S

Stuart

Dear All

I hope someone can assist.

I am trying to add the " symbol to the beginning and end of my cell
values.

I have dates in some of the columns so I do not want any of the
formatting changed.

For example in cell A1 I have apple. I would like this to read
"apple" or in cell B1 I have the date 29-Feb-2008. I would like this
to read "29-Feb-2008"

Hope you help and thanks in advance,

Stuart
 
D

Dave Peterson

You could use a macro:

Option Explicit
Sub Testme()
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 "Please select a nicer range!"
Exit Sub
End If

For Each myCell In myRng.Cells
myCell.Value = Chr(34) & myCell.Text & Chr(34)
Next myCell
End Sub


If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

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