ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how do I insert an ' in front of many rows of numbers? (https://www.excelbanter.com/excel-discussion-misc-queries/23467-how-do-i-insert-front-many-rows-numbers.html)

jnycks

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

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



"jnycks" wrote:

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


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)


"jnycks" wrote in message
...
I have a column of numbers 1,800 rows long that needs an ' in front of

every
row. How do I do this?





All times are GMT +1. The time now is 11:05 PM.

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