Sub CréerOnglets()
Dim t, i&, nom$, vis%, s As Object, n&
Application.ScreenUpdating = False
On Error Resume Next
t = Sheets("Base").[A1].CurrentRegion
For i = 2 To UBound(t)
If IsError(Sheets(t(i, 1))) Then GoTo 1
nom = CStr(t(i, 2))
If IsError(Sheets(nom)) Then
If nom <> "" Then
vis = Sheets(t(i, 1)).Visible
Sheets(t(i, 1)).Visible = True
Sheets(t(i, 1)).Copy Before:=Sheets(1)
Sheets(1).Name = nom
Sheets(1).Unprotect "1234" 'adapter le mot de passe
Sheets(1).[C7] = nom 'nom de l'élève
Sheets(1).Protect "1234"
Sheets(t(i, 1)).Visible = vis 'état initial
End If
End If
1 Next
'---placement en tête des onglets autres que ceux des élèves---
For Each s In Sheets
If IsError(Application.Match(s.Name, Application.Index(t, , 2), 0)) _
Then s.Move Before:=Sheets(1): n = n + 1
Next
'---classement des onglets des élèves dans l'ordre de la feuille---
For i = 2 To UBound(t)
If CStr(t(i, 2)) <> "" Then _
Sheets(CStr(t(i, 2))).Move After:=Sheets(n): n = n + 1
Next
Sheets("Base").Activate
End Sub