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
| Private Sub CommandButton1_Click()
Select Case UserForm8.Frame1.OptionButton1.Value
Case Is = "Vrai"
Dim i As Integer
i = 0
Dim j As Integer
j = 0
Dim Wb As Excel.workbook
Set Wb = ThisWorkbook
Dim Ws As Excel.Worksheet
Set Ws = GetWorksheet("CALCULS ADM")
Dim Ligne As Long
Ligne = Ws.Range("B99:B107").End(xlUp).Offset(1, 0).Row + 98
Dim Colonne As Integer
Colonne = Ws.Range("A100:CJ100").End(xlToLeft).Offset(0, 1).Column
Dim Cellule As Excel.Range
Set Cellule = Ws.Cells(Ligne, Colonne)
On Error GoTo Line2
Dim Ctrl As Control
Set Control = Me.UserForm8.Controls("LISSAGE2: I" & i & "J" & j)
Do While Not IsError(CDbl(Replace(Control.Caption, "LISSAGE2: ", "")))
Debug.Print IsError(CDbl(Replace(Control.Caption, "LISSAGE2: ", "")))
On Error GoTo Line1
Do While Not IsError(CDbl(Replace(Control.Caption, "LISSAGE2: ", "")))
Select Case Controls("MyTextBoxI" & i & "J" & j).Value
Case Is <> ""
Cellule.Value = CDbl(Replace(Control.Caption, "LISSAGE2: ", "")) + Controls("MyTextBoxI" & i & "J" & j).Value
Case Is = ""
Cellule.Value = CDbl(Replace(Control.Caption, "LISSAGE2: ", ""))
End Select
j = j + 1
Set Cellule = Cellule.Offset(0, 1).Select
If j = 12 Then
Exit Do
End If
Loop
Line1:
j = 0
i = i + 1
Loop
Line2:
Case Is = "Faux"
End Select
End Sub
private Function GetWorksheet(byVal Name as string) As Excel.Worksheet
Dim Wb As Excel.Workbook
Set Wb = ThisWorkbook
Dim Ws As Excel.Worksheet
Set Ws = Wb.Worksheets(Name)
Set GetWorksheet = Ws
End Function |
Partager