Need simple little macro - edit add 3 spaces

J

John Grossman

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
 
B

Bob Phillips

Activecell.Value = " " & Activecell.Value

--

HTH

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

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
 
G

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
 
B

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
 
Top