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
| Option Explicit
Public Const rowActFirst = 3 ' Premier actionneur après l'en-tête
Public Const colSignal = 1 ' Première colonne le signal est ...
Public Const colTenant = colSignal + 1 ' N° d'actionneur
' ... à compléter
Public Const colTypeCable = 11 ' colonne "J" contient le type de cable tel que 1050
Public Const typeCable1050 = 1050 ' Trouver un nom plus explicite
Public Const typeCable1051 = 1051 ' cable ...
Public Const typeCable1052 = 1052 ' cable ...
Sub BtnBrin_Click()
Dim indRow As Integer, nbrBrin As Integer, typeCable As Integer, indBrin As Integer
indRow = rowActFirst
While Cells(indRow, colSignal) <> ""
typeCable = CInt(Cells(indRow, colTypeCable))
Select Case typeCable
Case typeCable1050
nbrBrin = 1
Case typeCable1051
nbrBrin = 2
Case typeCable1052
nbrBrin = 3
Case Else
nbrBrin = 0
End Select
If nbrBrin > 0 Then ' Gestion des brins
Rows(indRow + 1).Resize(nbrBrin).Insert Shift:=xlDown ' Insertion sous l'actionneur
For indBrin = 1 To nbrBrin ' Dupliquer l'actionneur courant
Rows(indRow).Copy Rows(indRow + indBrin) ' dans chaque brin.
Next
indRow = indRow + nbrBrin ' Sauter les brins ajoutés
End If
indRow = indRow + 1
Wend
End Sub |
Partager