[COLOR="DarkSlateGray"][B]Private Sub Worksheet_Change(ByVal Target As Range)
Dim oRef As String, nRef As Long, rRef As Long
[COLOR="SeaGreen"]'=== Paramètres :[/COLOR]
oRef = "C2" [COLOR="SeaGreen"]'Adresse de la première cellule de la liste des modèles.[/COLOR]
nRef = 9 [COLOR="SeaGreen"]'Nombre maximum de modèle(s).
'================[/COLOR]
rRef = Range(oRef).Row
If Not Intersect(Target, Range(oRef).Resize(Rows.Count - rRef, nRef).Offset(1, 0)) Is Nothing And Not IsEmpty(Target.Cells(1, 1).Value) Then
Application.ScreenUpdating = False
On Error GoTo modèle_inexistant
ThisWorkbook.Sheets(Cells(rRef, Target.Cells(1, 1).Column).Value).Copy After:=Me
On Error GoTo nom_incorrect
ActiveSheet.Name = CStr(Target.Cells(1, 1).Value)
On Error GoTo 0
Me.Hyperlinks.Add Anchor:=Target, Address:="", SubAddress:=ActiveSheet.Name & "!A1"
Me.Activate
Application.ScreenUpdating = True
End If
Exit Sub
modèle_inexistant:
MsgBox "Il n'existe pas de feuille-modèle nommée " & """" & CStr(Cells(rRef, Target.Cells(1, 1).Column).Value) & """"
End
nom_incorrect:
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
Me.Activate
Target.Cells(1, 1).Select
Application.ScreenUpdating = True
MsgBox "Il existe déjà une feuille nommée " & """" & CStr(Target.Cells(1, 1).Value) & """" & _
vbLf & "ou ce nom est incorrect."
End
End Sub[/B][/COLOR]