Bonjour

Je cherche à appliquer une macro automatique inscrite dans thisworkbook à toutes les feuilles sauf la premiere.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
 
 
'pour spécifier la feuille 2
For Sheet = 2 To Sheets.Count
 
 
 Dim rwIndex As Long, colIndex As Long
 
For rwIndex = 2 To 33
    For colIndex = 3 To 8
           If (sh.Cells(rwIndex, colIndex).Value = sh.Cells(8, colIndex - 1).Value Or _
           sh.Cells(rwIndex, colIndex).Value = sh.Cells(9, colIndex - 1).Value Or _
           sh.Cells(rwIndex, colIndex).Value = sh.Cells(21, colIndex - 1).Value) _
           And sh.Cells(rwIndex, colIndex).Value <> "" Then
            MsgBox "vous n'avez pas le droit"
            ActiveCell.Value = ""
            Exit Sub
            End If
    Next colIndex
Next rwIndex
 
Next
 
end sub
Mais il y a probablement un problème sur Activecell.value. Il semble exécuter le code même si je bricole sur la première feuille.
La boucle sur sheet n'est pas la bonne instruction ?
Merci par avance