Re : Copier plusieurs cellules avec pas sur vba
Bonjour a tous
Une version vba
NB: en feuil2 j'ai modifié les formules lignes 3 (pour etre homogene avec ligne 4 et suivantes)
Bonjour pierrejean,
Cette macro correspond exactement à ce que je voulais! Merci beaucoup!
Si je comprends bien, si j'ajoute une colonne de donnée et que je veux changer le pas de temps (20mn au lieu de 30mn). Je modifie ta macro de la manière ci-après.
Mes connaissances VBA etants très limitées, mais désirant meiux apprendre, pourriez vous m'expliquer brièvement à quoi correspondent les différentes étapes (que fait la machine) ?
Et encore merci!
Macro modifiée:
Sub test()
Sheets("Feuil3").Cells.ClearContents
Sheets("Feuil1").Range("A1:F1").Copy Destination:=Sheets("Feuil3").Range("A1")
ligne = 2
For n = 2 To Sheets("Feuil1").Range("A65536").End(xlUp).Row
If Int(Sheets("Feuil1").Range("A" & n)) = Sheets("Feuil1").Range("A" & n) Then
debut = n
Exit For
End If
Next n
tablo = Sheets("Feuil1").Range("A1:F" & Sheets("Feuil1").Range("A65536").End(xlUp).Row)
For n = LBound(tablo, 1) + 1 To UBound(tablo, 1)
tot1 = tot1 + tablo(n, 2)
tot2 = tot2 + tablo(n, 3)
tot3 = tot3 + tablo(n, 4)
tot4 = tot4 + tablo(n, 5)
tot5 = tot5 + tablo(n, 6)
If (n - debut) Mod 20 = 0 Then
Sheets("Feuil3").Cells(ligne, 1) = tablo(n, 1)
Sheets("Feuil3").Cells(ligne, 2) = tot1 / 20
Sheets("Feuil3").Cells(ligne, 3) = tot2 / 20
Sheets("Feuil3").Cells(ligne, 4) = tot3 / 20
Sheets("Feuil3").Cells(ligne, 5) = tot4 / 20
Sheets("Feuil3").Cells(ligne, 6) = tot5 / 20
tot1 = 0
tot2 = 0
tot3 = 0
tot4 = 0
tot5 = 0
ligne = ligne + 1
End If
Next n
Sheets("Feuil3").Cells(2, 2) = Sheets("Feuil1").Range("B" & debut - 1)
Sheets("Feuil3").Cells(2, 3) = Sheets("Feuil1").Range("C" & debut - 1)
Sheets("Feuil3").Cells(2, 4) = Sheets("Feuil1").Range("D" & debut - 1)
Sheets("Feuil3").Cells(2, 5) = Sheets("Feuil1").Range("E" & debut - 1)
Sheets("Feuil3").Cells(2, 6) = Sheets("Feuil1").Range("F" & debut - 1)
End Sub