only inserts leading 0's not trailing.
Since you mention a previous column, your numbers obviously aren't in column A.
Is that a text 02 or a 2 formatted that way?
Sub test()
Dim c As Range
For Each c In Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row)
If c.Offset(, -1) = "02" Then
c.NumberFormat = "@"
c = Format(c, String(8, "0")) & String(6, "0")
End If
Next
End Sub
Code:Sub test() Dim c As Range For Each c In Range("B1:B" & Range("B" & Rows.Count).End(xlUp).Row) If c.Offset(, -1) = "02" Then c.NumberFormat = "@" c = Format(c, String(8, "0")) & String(6, "0") End If Next End Sub