Hi,
I'm looking for a piece of code that can add an auto number to a cell when the rest of the row is populated.
It doesn't need to have a pre-fix. I've tried this:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myVal As Variant
If Target.Column <> 2 Then Exit Sub
If Target.Row = 4 Then
Target.Offset(0, -1).Value = "0001"
Else
myVal = Split(Target.Offset(-1, -1).Value, "-")(1)
Target.Offset(0, -1).Value = "001-" & Format(Val(myVal + 1), "0000")
End If
End Sub
And it works! But only for one row - it wont take the code down onto the next row.
Can anyone give me any advice?
Thanks
Naomi
Bookmarks