how do I insert an ' in front of many rows of numbers?

J

jnycks

I have a column of numbers 1,800 rows long that needs an ' in front of every
row. How do I do this?
 
P

Peter Rooney

Hold down [Alt]+F11
From the menu "Insert", "Module"
Copy and paste this code into the module
Hold down [Alt]+F11 to go back to your workbook
Select the cells to which you want to add an apostrophe
Hold down [Alt]+F8
Double Click "AddApostropheToRange"

This should do it.

Hope this helps

Pete

Sub AddApostropheToRange()
Dim CellToModify As Object
For Each CellToModify In Selection
CellToModify.Formula = "'" & CellToModify.Formula
Next CellToModify
End Sub

Note Line 4 contains an apostrophe surrounded by double quotes
 
B

Bob Phillips

If you just need them to be text, format the column as text.

If you need that extra character

iLastRow = Cells(Rows.Count,"A").End(xlUp).Row
For i = 1 to iLastRow
Cells(i,"A").Value = "'" & Cells(i,"A").Value
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Top