ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to add the " symbol to the beginning and end of cells selected (https://www.excelbanter.com/excel-programming/409684-macro-add-symbol-beginning-end-cells-selected.html)

Stuart[_3_]

Macro to add the " symbol to the beginning and end of cells selected
 
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

Dave Peterson

Macro to add the " symbol to the beginning and end of cells selected
 
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

Stuart wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 09:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com