add leading character

  • Thread starter Satnam Randhawa
  • Start date
S

Satnam Randhawa

I have a column of numbers to which I want to add a leading apostrophe. how
do i do it in one go?
 
G

Gary''s Student

Select the cells you want to process and run this:

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

Satnam Randhawa

doesnt work...
any other suggestions?

Gary''s Student said:
Select the cells you want to process and run this:

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

Satnam Randhawa

I have selected the cells but its showing an error in the code when i try to
write it in the macro..
 
L

L. Howard Kittle

Maybe you need to declare the variables.

Sub quote_me()
Dim apos As Variant
Dim r As Variant
apos = Chr(39)
For Each r In Selection
r.Value = apos & r.Text
Next
End Sub

HTH
Regards,
Howard
 
D

dave m

Hello there.

Why not use something simple like:
In a cell next to the top piece of data type a space and apostrophe.
Then in an empty cell on the same line use =right(a1,1) & a2
where A1 is the cell with the apostrophe and a2 is the cell with your number .
Once done rip it down as far as you want.
If needed highlight new column of data and copy- Paste special values over
the top of your formulas to hard case them in.

Dave
 

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