Sub CréerOnglets()
Application.ScreenUpdating = False
Dim tablo() As Variant
With Sheets("Suivi")
LastLine = .Range("A" & .Rows.Count).End(xlUp).Row 'on cherche la dernière ligne de la feuille
LastCol = .UsedRange.Columns.Count 'on cherche la dernière colonne de la feuille
tablo = .Range("A2").Resize(LastLine - 1, LastCol).Value 'on met toutes les data dans un tableau VBA
End With
For j = LBound(tablo, 2) + 1 To UBound(tablo, 2) 'pour chaque colonne
If Not (FeuilleExiste("nr" & tablo(1, j))) Then
Sheets("Formulaire").Copy after:=Sheets(Sheets.Count) 'on copie la feuille Formulaire
Sheets("Formulaire (2)").Name = "nr" & tablo(1, j) 'qu'on renomme
With Sheets("nr" & tablo(1, j)) 'dans cette nouvelle feuille
For i = LBound(tablo, 1) To UBound(tablo, 1)
.Range("B7").Offset(i - 1, 0) = tablo(i, j) 'on colle toutes les lignes
Next i
End With
End If
Next j
Application.ScreenUpdating = True
End Sub
Function FeuilleExiste(NomFeuille As Variant) As Boolean
With ActiveWorkbook
FeuilleExiste = False
For Each ws In .Sheets
If ws.Name = NomFeuille Then
FeuilleExiste = True
Exit For
End If
Next ws
End With
End Function