Private Sub I3_Clic() If (I3.Caption <> "") Then jour = Range("I3") Mois = Range("I9") Année = Range("I10") A = action(Année, Mois, jour) End If End Sub Private Sub J3_Clic() If (J3.Caption <> "") Then jour = Range("J34") Mois = Range("J9") Année = Range("J10") A = action(Année, Mois, jour) End If End Sub Function action(Année, Mois, jour) Nommois = MonthsBox.Value If FeuilleExiste("Agenda_Jour_" & jour & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Visible = True Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Activate ElseIf Not FeuilleExiste("Agenda_Jour_" & "Jour" & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_vide").Copy After:=Sheets("Feuil 3") Worksheets("Agenda_Jour_vide (2)").Name = "Agenda_Jour_" & jour & "_" & Mois & "_" & Année Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B2") = jour Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B9") = "jeudi" Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("C9") = jour Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("D9") = Nommois Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B10") = Année Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Activate End If End Function
If InStr(1, LCase(ctl.Name), "cmd") Then
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSub test() 'boucle sur les controls d'une feuille For Each s In Worksheets(1).Shapes If s.Type = 8 or s.Type = 12 Then 'si c'est un bouton Debug.Print s.Name End If Next End Sub
Private Sub I3_Click() If (I3.Caption <> "") Then Jour = Range("I3") Mois = Range("I9") Année = Range("I10") Nommois = MonthsBox.Value If FeuilleExiste("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Visible = True Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Activate ElseIf Not FeuilleExiste("Agenda_Jour_" & "Jour" & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_vide").Copy After:=Sheets("Feuil 3") Worksheets("Agenda_Jour_vide (2)").Name = "Agenda_Jour_" & Jour & "_" & Mois & "_" & Année Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Range("B2") = Jour Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Range("B9") = "jeudi" Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Range("C9") = Jour Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Range("D9") = Nommois Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Range("B10") = Année Worksheets("Agenda_Jour_" & Jour & "_" & Mois & "_" & Année).Activate End If End If End Sub
Nommois = MonthsBox.Valueet je l'ai enlever de la fonction puis je l'ai mis dans le boutton comme sa , sa evite de recrée la fonction avec chaque nouvel page .
Private Sub J3_Clic() If (J3.Caption <> "") Then B9 = "vendredi" jour = Range("J3") Mois = Range("J9") Année = Range("J10") A = action(Année, Mois, jour) End If End Sub Function action(Année, Mois, jour) Nommois = MonthsBox.Value If FeuilleExiste("Agenda_Jour_" & jour & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Visible = True Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Activate ElseIf Not FeuilleExiste("Agenda_Jour_" & "Jour" & "_" & Mois & "_" & Année) Then Worksheets("Agenda_Jour_vide").Copy After:=Sheets("Feuil 3") Worksheets("Agenda_Jour_vide (2)").Name = "Agenda_Jour_" & jour & "_" & Mois & "_" & Année Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B2") = jour Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B9") = "vendredi" Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("C9") = jour Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("D9") = Nommois Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Range("B10") = Année Worksheets("Agenda_Jour_" & jour & "_" & Mois & "_" & Année).Activate End If End Function
8 août 2013 à 10:28
(c'est ça de faire plusieurs langages en même temps...on s'y perd... ^^ )