Here you go. This belongs in the ThisWorkbook object.
If you can come up with a rule of how to get the XXX (GSA, etc) then we can write that into the code. Otherwise they all need to be hardcoded as the two from your example are now.
Private Sub Workbook_SheetChange(ByVal ws As Object, ByVal Target As Range)
If (Target.Column = 4 Or Target.Column = 5 Or Target.Column = 6) And Target.Row > 1 Then
Application.EnableEvents = False
If ws.Range("A" & Target.Row) = "" Then
ws.Range("A" & Target.Row).Value = Format(Now, "yyyy-mm-dd-hh:mm")
End If
If ws.Range("B" & Target.Row) = "" Then
s = ws.Name
If s = "George's - Cassville" Then
t = "GCM"
ElseIf s = "George's - Springdale" Then
t = "GSA"
End If
If ws.Range("B" & Target.Row - 1).Value = "Serial Number" Or ws.Range("B" & Target.Row - 1) = "" Then
x = "01"
Else
x = CLng(Right(ws.Range("B" & Target.Row - 1).Value, 2)) + 1
If x < 10 Then x = "0" & CStr(x)
End If
ws.Range("B" & Target.Row).Value = t & "-" & Format(Date, "yymmdd") & "-" & x
End If
Application.EnableEvents = True
End If
End Sub
Bookmarks