ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need simple little macro - edit add 3 spaces (https://www.excelbanter.com/excel-worksheet-functions/38310-need-simple-little-macro-edit-add-3-spaces.html)

John Grossman

Need simple little macro - edit add 3 spaces
 
How do I do F2 - home - add 3 spaces and enter.
Don't want it to carry over name I'm editing - each row different



Bob Phillips

Activecell.Value = " " & Activecell.Value

--

HTH

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


"John Grossman" wrote in message
...
How do I do F2 - home - add 3 spaces and enter.
Don't want it to carry over name I'm editing - each row different





Bernie Deitrick

John,

With a formula, for a string in A1:

=" " & A1

Copy down to match your cells, then copy / pastespecial values and get rid of your original values.

With a macro, select the cells that you want to change, and run this macro

Sub Add3Spaces()
Dim myCell As Range
For Each myCell In Selection
myCell.Value = " " & myCell.Value
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"John Grossman" wrote in message ...
How do I do F2 - home - add 3 spaces and enter.
Don't want it to carry over name I'm editing - each row different




Gary's Student

Assuming you want to pre-pad selected cells with three spaces, try:

Sub padit()
Dim r As Range
Set r = Selection
r.Value = " " & r.Value
End Sub

--
Gary's Student


"John Grossman" wrote:

How do I do F2 - home - add 3 spaces and enter.
Don't want it to carry over name I'm editing - each row different




Bernie Deitrick

Gary's Student,

That code should have given you an error when you tested it on a multi-cell selection.

HTH,
Bernie
MS Excel MVP


"Gary's Student" wrote in message
...
Assuming you want to pre-pad selected cells with three spaces, try:

Sub padit()
Dim r As Range
Set r = Selection
r.Value = " " & r.Value
End Sub

--
Gary's Student


"John Grossman" wrote:

How do I do F2 - home - add 3 spaces and enter.
Don't want it to carry over name I'm editing - each row different







All times are GMT +1. The time now is 02:58 PM.

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