Bonjour à toutes et à tous

Actuellement je recherche une solution au problème suivant : je possède un formulaire excel qui est protégé dès son ouverture sauf 3 cases correspondantes à des informations liées à des menus « déroulant ». Une fois que mon formulaire est « starté », je cherche à protéger les dites cellules. Voici le code à ce propos (début de ma page MODULE) déclenché à partir du module START TIME (protection 3 entrées) :


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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Option Explicit
 
Public Const FORMULAIRE_PM_WK_NAME As String = "formulaire PM"
Public Const LAM_PARTS_WK_NAME As String = "LAM parts log"
Public Const LISTS_WK_NAME As String = "lists"
Public Const DATA_TPM_WK_NAME As String = "data TPM"
Public Const DATA_SUPPORT_WK_NAME As String = "data SUPPORT"
 
Public Const COLUMN_TRIGRAM As Long = 8
Public Const COLUMN_TARGET As Long = 10
Public Const COLUMN_END_TIME As Long = 13
Public Const COLUMN_GAP As Long = 15
 
Dim theWk As Worksheet
Dim fullPath As String
 
Sub StartPM()
 
' Start Time PM et protection  (Time0 et 3 entrées menu)
 
ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Unprotect "password"
 
Dim Start As Range
Set Start = ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Cells(11, 4)
Start.Value = Now
 
Dim Tool As Range
Set Tool = ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Cells(7, 4)
Selection.Locked = True
 
Dim PM As Range
Set PM = ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Cells(8, 4)
Selection.Locked = True
 
Dim Check As Range
Set Check = ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Cells(9, 4)
Selection.Locked = True
 
ThisWorkbook.Worksheets(FORMULAIRE_PM_WK_NAME).Protect "password"
 
Call VisuPointeur
 
End Sub
Je ne comprends pas pourquoi ce type de code ne fonctionne que pour la troisième case (CHECK) tandis que les 2 autres peuvent malheureusement être ensuite modifiées (TOOL et PM). Les 3 cases sont pourtant identiques en ce qui concerne leur déclaration (format cells – case locked non cochée). Pourrait-on m’indiquer une piste et où chercher pour résoudre ce problème ?

Merci par avance pour votre aide

Laurent