Re : Répéter une macro sur plusieurs feuille à l'aide de thisworkbook
Ben en fait je suis pas si malin que ça, Staple1600... je ne suis pas arrivé à faire fonctionner les autres macros en suivant l'exemple que tu m'as donnné. J'ai juste modifier la première macro pour la rendre inactive sur certaines pages.
Si tu peux m'aider encore une fois, je te donne le code complet de la page.
La première macro est celle que tu as modifié et qui fonctionne. Les autres sont à modifier avec l'aide des Sh.
Je mets aussi en pièce jointe un document ne contenant que la macro dans thisworkbook.
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
'position des cellules contenant un calendrier
If Sh.Name Like "Présences" Then Exit Sub
If Sh.Name Like "Absences" Then Exit Sub
If Sh.Name Like "Indemnités" Then Exit Sub
If Sh.Name Like "Stagiaires" Then Exit Sub
If Sh.Name Like "Parametres" Then Exit Sub
If Not Intersect(Target, Sh.[C13:C1000]) Is Nothing Then
F_calendar.Show
End If
If Not Intersect(Target, Sh.[E13:E1000]) Is Nothing Then
F_calendar.Show
End If
If Not Intersect(Target, Sh.[H13:H1000]) Is Nothing Then
F_calendar.Show
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'ouverture automatique des liste déroulantes
On Error Resume Next
If Not Intersect([A13:A1000], Target) Is Nothing And Target.Count = 1 Then
typ = Target.Validation.Type
If typ = 3 Then SendKeys "%{down}": Target.Select
End If
On Error Resume Next
If Not Intersect([D13
1000], Target) Is Nothing And Target.Count = 1 Then
typ = Target.Validation.Type
If typ = 3 Then SendKeys "%{down}": Target.Select
End If
On Error Resume Next
If Not Intersect([F13:F1000], Target) Is Nothing And Target.Count = 1 Then
typ = Target.Validation.Type
If typ = 3 Then SendKeys "%{down}": Target.Select
End If
On Error Resume Next
If Not Intersect([G13:G1000], Target) Is Nothing And Target.Count = 1 Then
typ = Target.Validation.Type
If typ = 3 Then SendKeys "%{down}": Target.Select
End If
On Error Resume Next
If Not Intersect([H13:H1000], Target) Is Nothing And Target.Count = 1 Then
typ = Target.Validation.Type
If typ = 3 Then SendKeys "%{down}": Target.Select
End If
End Sub
Private Sub Worksheet_Calculate()
'message en cas de dépassement nombre HS
If [F6] >= 100 Then
MsgBox "Le nombre d'heures supplémentaires doit être inférieur à 100 !" & vbLf _
& "La dernière action va être annulée !", 48
On Error Resume Next 'si l'action ne peut pas être annulée
With Application
.EnableEvents = False 's'il y a une macro Worksheet_Change
.Undo 'annule l'action
.OnRepeat "", "" 'empêche de répéter l'action
.EnableEvents = True
End With
End If
End Sub
Bonne journée !
Frédéric