Inserting Quotation Marks in all Cells

G

Guest

Hi!

I have a co-worker who needs to insert quotation marks in the entire
worksheet. It contains both numbers and text. The quotation marks need to
be inserted around each individual cells data.

Can someone help?
 
G

Guest

Enter this small macro:

Sub quoteit()
Dim r As Range
For Each r In Selection
If IsEmpty(r.Value) Then
Else
r.Value = Chr(34) & r.Value & Chr(34)
End If
Next
End Sub

Select all or some portion of the worksheet and run the macro. It will put
quote marks before and after the contents of all selected non-empty cells
 
G

Guest

Hey Thanks!

Now, can you make it insert quotation marks in empty cells as well as cells
containing data?
 
G

Guest

Yes. We will just get rid of the IF:

Sub quoteit()
Dim r As Range
For Each r In Selection
r.Value = Chr(34) & r.Value & Chr(34)
Next
End Sub
 
G

Guest

Okay then! Thanks sooo much!

Gary''s Student said:
Yes. We will just get rid of the IF:

Sub quoteit()
Dim r As Range
For Each r In Selection
r.Value = Chr(34) & r.Value & Chr(34)
Next
End Sub
 

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