Sub BoutonPlan()
Dim s$, Cible$
s = ActiveSheet.DrawingObjects(Application.Caller).Caption & " "
Cible = s & Range("K4") & " (" & IIf(Left(Range("Q4"), 3) = "Pri", "1", "2") & ")"
If ExistWorkSheet(Cible) Then
Worksheets(Cible).Activate
Else
If MsgBox("le plan n'existe pas." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Voulez-vous le créer maintenant ?", vbQuestion + vbYesNo) = vbYes Then
MsgBox "Allons-y !"
ActiveWorkbook.Unprotect ""
Sheets("PLAN POTAGER (vierge)").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = Cible
End If
End If
End Sub
Function ExistWorkSheet(NomFeuille$) As Boolean
Dim Test_Feuille As Worksheet
On Error Resume Next
Set Test_Feuille = Sheets(NomFeuille) 'tout type de feuille, feuille standard, feuille graphique, feuille dialogue
Feuille_Existe = Not Test_Feuille Is Nothing
Err.Clear
End Function