Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, tablo, i&, n&, maxi&
Set r = [BDD[code_barre]] 'colonne du tableau structuré
r.Name = "Code" 'plage nommée
tablo = r.Resize(, 2) 'matrice plus rapide, au moins 2 éléments
For i = 1 To UBound(tablo)
n = Val(Replace(tablo(i, 1), "SB-", ""))
If n > maxi Then maxi = n
Next
Application.ScreenUpdating = False
Application.EnableEvents = False
For i = 1 To UBound(tablo)
If Not tablo(i, 1) Like "SB-#*" Then maxi = maxi + 1: r(i) = "SB-" & Format(maxi, "000000")
Next
Application.EnableEvents = True
End Sub