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
|
Private Sub Valider_Click()
Dim i As Integer, k As Integer, j As Integer
Dim lavaleur As String
Dim d As Byte, e As Byte
Dim ress()
ThisWorkbook.Worksheets("Ressources").Activate
With ThisWorkbook.Worksheets("Ressources")
derl = .Cells(Rows.Count, 1).End(xlUp).Row
derc = .Cells(1, Cells.Columns.Count).End(xlToLeft).Column
ress = .Range(Cells(1, 1), Cells(derl, derc)).Value
End With
lavaleur = ""
For i = 0 To Lb_codi.ListCount - 1
With Lb_codi
If .Selected(i) = True Then
d = InStr(.List(i), "(") + 1
e = InStr(.List(i), ")")
lavaleur = lavaleur & ";" & Mid(.List(i), d, e - d)
End If
End With
Next i
For k = LBound(ress, 2) To UBound(ress, 2)
If CStr(ress(1, k)) = Me.CB_lofc.text Then
For j = LBound(ress, 1) To UBound(ress, 1)
If CStr(ress(j, 1)) = Me.Cb_sem.Value Then
With Cells(j, k)
'ôter le 1er ";"
.Value = Right(lavaleur, Len(lavaleur) - 1)
'ajustement de la largeur de colonne
.Columns.AutoFit
End With
End If
Next
End If
Next
Me.Hide
Unload Me
End Sub |