Single quotation mark prefix

C

Chris Hankin

Hello,

Could some one please help me with the following?

In column B of my workbook, I have a list of text data (5500 lines) - an
example of this is given below. I wish to prefix each data value with a
single quotation mark as shown below, but I do not know how to do this.

Cell B2: ABC123-UYT
Cell B3: 001HF-367
Cell B4: 00001-KML-8741

I need to change the above to this:

Cell B2: 'ABC123-UYT
Cell B3: '001HF-367
Cell B4: '00001-KML-8741


Any help would be greatly appreciated.

Thanks,

Chris.




*** Sent via Developersdex http://www.developersdex.com ***
 
G

Gary''s Student

Select the cells you want to convert and run:

Sub dont_quote_me()
apos = Chr(39)
For Each r In Selection
r.Value = apos & apos & r.Value
Next
End Sub

Note that you need two single quotes, not just one.
 
C

Chris Hankin

Thanks Gary for your reply - just a question please - why do I need
quote: Note that you need two single quotes, not just one. Unquote.?

A single quotation mark seems to work fine - so will your code work OK
to produce a single quotation mark?

Thanks,

Chris.



*** Sent via Developersdex http://www.developersdex.com ***
 
G

Gary''s Student

If you select a cell and manually type two single quotes and the text
APPLES
the formula bar will show both quotes, but the cell only one. Excel treats
the first single quote as a special text marker and not as part of the string.
 

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