Adding a Zero

L

Little Penny

I'm looking for a macro that will add a zero of the first character in
column starting in the row 2 (W2 to Last row with data).

Example:

This:

aaaaaaa
bbbbbb
cccccc

Would look like:

This

a0aaaaaa
b0bbbbb
c0ccccc



Little Penny
 
B

Bob Phillips

Dim LastRow As Long
Dim i As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To LastRow

.Cells(i, "A").Value = Left(.Cells(i, "A").Value, 1) & "0" & _
Right(.Cells(i, "A").Value,
Len(.Cells(i, "A").Value) - 1)
Next i
End With


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

Rick Rothstein \(MVP - VB\)

Give this a try...

Sub AddZero()
Dim X As Long
Dim LastRow As Long
With Worksheets("Sheet3")
LastRow = .Cells(Rows.Count, "W").End(xlUp).Row
For X = 2 To LastRow
With .Cells(X, "W")
.Value = Left(.Value, 1) & "0" & Mid(.Value, 2)
End With
Next
End With
End Sub

Rick
 
Top