Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim serial As Variant 'current serial number
- 'turn off events to stop inadvertent looping
- Application.EnableEvents = False
- ' assumes that serial number will be created when column B is altered
- If Not Intersect(Target, Range("B:B")) Is Nothing Then
- 'extract the serial number
- serial = Replace(ThisWorkbook.Names("SerialNumber").Value, "=", "") + 0
- 'apply to column C (adjust to suit)
- Range("C" & Target.Row).Value = "M-" & serial & Format(Date, "ddmmyy")
- 'increment serial number
- ThisWorkbook.Names("SerialNumber").RefersTo = serial + 1
- End If
- 'restore events
- Application.EnableEvents = True
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement