' Feuille Leurres
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
' code Feuille Leurres
' Gre l'ajout d'une rivire dans la colonne Rivire
  Dim lo As ListObject
  Dim rng As Range
  Dim numCol%
  If Not Intersect(Target, Range("tb_leurres[Leurre_type]")) Is Nothing And Target.Count = 1 Then
    If Target.Value <> "" Then
      With Range("tb_leurres[#headers]")
        Set rng = .Find(Target.Value, LookIn:=xlValues)
        If Not rng Is Nothing Then
          MsgBox "Cette type de leurre existe dj": Exit Sub
        Else
          Set lo = ActiveSheet.ListObjects("tb_leurres")
          numCol = Target.Column + 1
          lo.ListColumns.Add (numCol) ' Ajoute une colonne
          lo.ListColumns(numCol).Name = Target.Value ' nomme une colonne
          Range("tb_leurres").Cells(1, numCol) = "Autre"
          ActiveSheet.Columns.AutoFit
        End If
      End With
    End If
  End If
End Sub
