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
| Private Sub validez_Click()
Dim PL As Range
Dim TheCell As Range
Dim I As Integer
Dim Coef
Set PL = O.Range("A1")
For I = 0 To Me.Choix.ListCount - 1
If Me.Choix.Selected(I) = False Then Set PL = IIf(PL.Cells.Count = 1, O.Rows(I + 9), Application.Union(PL, O.Rows(I + 9)))
Next I
PL.EntireRow.Hidden = True
Set PL = O.Range("A1")
For I = 2 To Me.ComboBox1.ListIndex + 1
Set PL = IIf(PL.Cells.Count = 1, O.Columns(I), Application.Union(PL, O.Columns(I)))
Next I
'PL.Select
For I = Me.ComboBox1.ListIndex + Me.ComboBox2.ListIndex + 3 To 39
Set PL = IIf(PL.Cells.Count = 1, O.Columns(I), Application.Union(PL, O.Columns(I)))
Next I
PL.EntireColumn.Hidden = True
O.Range("A5").Select
Set PL = O.Range("B9", O.Cells(O.Rows.Count, "AM").End(xlUp)).SpecialCells(xlCellTypeVisible)
For Each TheCell In PL
'On remplace le . par une virgule si besoin
'Il serait préférable de faire en sorte que la saisi dans le userform soit forcément numérique, il y a des exemples sur le forum ou dans la FAQ
Coef = CSng(Replace(Me.TextBox1.Text, ".", ","))
'On verifie qie coef soit numeric
If IsNumeric(Coef) Then
TheCell.Value = TheCell.Value * CSng(Coef)
Else
MsgBox "Attention le coéficient doit être une valeur numérique", , "Coéficient non numérique"
End If
Next
Unload Me
End Sub |
Partager