Dim formule1, formule2, formule3 As String
j = 8 W = 0
Do While Not (IsEmpty(Range("A" & j))) j = j + 1 Loop
j = range("A8:A" & rows.count).SpecialCells(xlCellTypeBlanks).Row
W = TextBox1.Value - (j - 8) If TextBox1.Value <= 8 Then
Private Sub rowchange() Dim ligne As Integer Dim formule1, formule2, formule3 As String j = 8 W = 0 Do While Not (IsEmpty(Range("A" & j))) j = j + 1 Loop W = TextBox1.Value - (j - 8) If TextBox1.Value <= 8 Then MsgBox ("Vous ne pouvez entrer un nombre d'actions inférieur à 8") Else Do While Not ((j - 8) = TextBox1.Value) If TextBox1.Value > (j - 8) Then Application.EnableEvents = False Range("A" & (j - 1) & ":CE" & (j - 1)).Copy Range("A" & j).Select Selection.Insert Range("A" & (j - 1) & ":A" & (j)).Select Selection.RowHeight = 30 j = j + 1 Range("B" & (j - 1) & ":H" & (j - 1)).Value = Null Application.EnableEvents = True Else If TextBox1.Value < (j - 8) Then Application.EnableEvents = False s = Str(j + 1) + ":" + Str(endrow) s = Replace(s, " ", "") Rows(j - 1).Delete Shift:=xlUp j = j - 1 Application.EnableEvents = True End If End If Loop 'Formule pour faire la somme de chaque temps Application.EnableEvents = False formule1 = "=SUM(F8:F" & (j - 1) & ")" Range("F" & j).Value = formule1 formule2 = "=SUM(G8:G" & (j - 1) & ")" Range("G" & j).Value = formule2 Application.EnableEvents = True formule3 = "=SUM(H8:H" & (j - 1) & ")" Range("H" & j).Value = formule3 End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub rowchange() Dim ligne As Integer Dim formule1, formule2, formule3 As String j = 8 W = 0 Do While Not (IsEmpty(Range("A" & j))) j = j + 1 Loop W = TextBox1.Value - (j - 8) If TextBox1.Value <= 8 Then MsgBox ("Vous ne pouvez entrer un nombre d'actions inférieur à 8") Else Do While Not ((j - 8) = TextBox1.Value) If TextBox1.Value > (j - 8) Then Application.EnableEvents = False Range("A" & (j - 1) & ":CE" & (j - 1)).Copy Range("A" & j).Select Selection.Insert Range("A" & (j - 1) & ":A" & (j)).Select Selection.RowHeight = 30 j = j + 1 Range("B" & (j - 1) & ":H" & (j - 1)).Value = Null Application.EnableEvents = True Else If TextBox1.Value < (j - 8) Then Application.EnableEvents = False s = Str(j + 1) + ":" + Str(endrow) s = Replace(s, " ", "") Rows(j - 1).Delete Shift:=xlUp j = j - 1 Application.EnableEvents = True End If End If Loop 'Formule pour faire la somme de chaque temps Application.EnableEvents = False formule1 = "=SUM(F8:F" & (j - 1) & ")" Range("F" & j).Value = formule1 formule2 = "=SUM(G8:G" & (j - 1) & ")" Range("G" & j).Value = formule2 Application.EnableEvents = True formule3 = "=SUM(H8:H" & (j - 1) & ")" Range("H" & j).Value = formule3 End If End Sub