I have data that I want to add up automatically every fifth row and the rest.
here is The following data:
<tbody>
</tbody>
code that I use is like this:
from the code above, it will only sums each fifth line, but the rest of the line will not be added together.
how the correct code to solve this issues
Thank you in advance
here is The following data:
1 | |
2 | |
3 | |
4 | |
5 | 15 |
6 | |
7 | |
8 | |
9 | |
10 | 40 |
11 | |
12 | ??? |
<tbody>
</tbody>
code that I use is like this:
Code:
Dim x As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = 5 To Lastrow Step 5
Range("B" & x).Value = Application.Sum(Range("A" & x & ":A" & x - 4))
Next
from the code above, it will only sums each fifth line, but the rest of the line will not be added together.
how the correct code to solve this issues
Thank you in advance