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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| Option Explicit
Const ColSignals As String = "C" 'First variant column in Boxes Sheet
Const ColVar1 As String = "G" 'First variant column in Boxes Sheet
Const ColVar2 As String = "P"
Const ColBox As String = "K"
Const ColInv As String = "D"
Const ColPol1 As String = "D"
Const ColPol2 As String = "L"
Const ColBoxName As String = "A"
Const ColSupp As String = "M"
Const ColPin As String = "I"
Const ColConnec As String = "H"
Public k As Integer
Private Sub Workbook_Open()
'Declarations
Dim i, j, BoxIndexRow As Integer
Dim r, r1 As Range
Dim BoxesAvailableTable(21)
Dim ColVar As Byte
Dim Boxname
Dim ColVarAscii
Dim YesNo(2) As String
Dim BoxNbr
Dim PinNumber
'-------------
'Declaration en dur de la table BoxAvailable
'-------------
ThisWorkbook.Sheets("BLABLA").Activate
With Sheets("BLABLA")
j = 0
For Each r In Columns(ColBox).Cells
If r.Row > 2 Then
If IsEmpty(r.Value) Then
If r.Row = 2 Then
MsgBox ("Configuration of Boxes is empty")
Exit For
Else
Exit For
End If
Else
j = j + 1
End If
End If
Next
k = 0
For Each r In .Columns("A").Cells
If r.Row > 2 Then
If IsEmpty(r.Value) Then
If r.Row = 3 Then
MsgBox ("Configuration of Signals is empty")
Exit For
Else
Exit For
End If
Else
k = k + 1
End If
End If
Next
' k contient le nombre de resource que l'utilisateur a entré
End With
ReDim BoxesTable(j - 1)
BoxIndexRow = 2
For i = 0 To (j - 1)
BoxesTable(i) = Range("A" & BoxIndexRow).Value
BoxIndexRow = BoxIndexRow + 1
Next
'----------------------------------------------------------------------------------------
With Sheets("BLABLA")
YesNo(0) = "HS"
YesNo(1) = "LS"
YesNo(2) = "NA"
For Each r In .Columns(ColPol2).Cells
If (r.Row > 2) Then
If IsEmpty(r.Offset(0, -11).Value) Then Exit For
With r.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(YesNo, ",")
.InputMessage = "Must be in the joined list"
End With
End If
Next
End With
With Sheets("BLABLA")
For Each r In Sheets("BLABLA").Columns(ColBox).Cells
If (r.Row > 2) Then
If (IsEmpty(r.Offset(0, -10).Value)) Then Exit For
With r.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(BoxesAvailableTable, ",")
.InputMessage = "Must be in the joined list"
End With
End If
Next
'----
YesNo(0) = "X"
YesNo(1) = "NOT USED"
For Each r In Sheets("BLABLA").Columns(ColVar2).Cells
If (r.Row > 2) Then
If IsEmpty(r.Offset(0, -15).Value) Then Exit For
For i = 0 To 32
With r.Offset(0, i).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=Join(YesNo, ",")
.InputMessage = "Must be in the joined list"
End With
Next i
End If
Next
End With
End Sub |
Partager