ineedmesome
New Member
- Joined
- Dec 28, 2017
- Messages
- 5
Hi guys,
I wanna sum the cells of each row in "Rentabilité 2" range and have the result in the column right next to it.
Here's the code i made so far, i managed to select the range under "Rentabilité 2", but don't know how to sum each row, do i need a for loop?
<colgroup><col><col><col><col><col span="2"><col><col span="12"><col><col></colgroup><tbody>
</tbody>
Thanks in advance !
I wanna sum the cells of each row in "Rentabilité 2" range and have the result in the column right next to it.
Here's the code i made so far, i managed to select the range under "Rentabilité 2", but don't know how to sum each row, do i need a for loop?
Code:
Sub sum()
Dim lngLastRow As Long
Dim lngLastCol As Long
Dim mc As Range
With Worksheets("data").Cells
Set mc = .Find("Rentabilité 2", LookIn:=xlValues).Offset(2)
If Not mc Is Nothing Then
lngLastRow = .Cells(Rows.Count, mc.Column).End(xlUp).Row
lngLastCol = .Cells(mc.Row, Columns.Count).End(xlToLeft).Column
.Range(mc, Cells(lngLastRow, lngLastCol)).Select
range_renta2 = .Range(mc, Cells(lngLastRow, lngLastCol)).Select
End If
End With
End Sub
AC FP Equity | FP FP Equity | MC FP Equity | GLE FP Equity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Date | PX_LAST | PX_LAST | PX_LAST | PX_LAST | Rentabilité | Scenarii | Rentabilité 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
35,88 | 44,27 | 155,45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
06/09/2016 | 35,785 | 44,095 | 156,15 | 32,16 | -0,0026513 | -0,00396 | 0,004493 | -0,01971 | 30,98275 | 30,9422 | 31,20489 | 30,45885 | -0,00066 | -0,00099 | 0,001123 | -0,004926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
07/09/2016 | 35,98 | 44,605 | 156,45 | 32,405 | 0,00543441 | 0,0115 | 0,001919 | 0,007589 | 31,23428 | 31,4243 | 31,12469 | 31,30166 | 0,001359 | 0,002875 | 0,00048 | 0,0018973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
08/09/2016 | 36,145 | 44,445 | 154,1 | 33,065 | 0,00457542 | -0,00359 | -0,01513 | 0,020163 | 31,20746 | 30,95357 | 30,59838 | 31,69771 | 0,001144 | -0,0009 | -0,00378 | 0,0050407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
09/09/2016 | 35,805 | 43,855 | 152,2 | 33,34 | -0,0094511 | -0,01336 | -0,01241 | 0,008283 | 30,77279 | 30,65262 | 30,68198 | 31,32337 | -0,00236 | -0,00334 | -0,0031 | 0,0020706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
12/09/2016 | 34,835 | 43,435 | 152 | 32,725 | -0,027465 | -0,00962 | -0,00131 | -0,01862 | 30,22341 | 30,76749 | 31,02418 | 30,49196 | -0,00687 | -0,00241 | -0,00033 | -0,004655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
13/09/2016 | 34,745 | 42 | 150,8 | 32,14 | -0,002587 | -0,0336 | -0,00793 | -0,01804 | 30,98474 | 30,03868 | 30,81975 | 30,50968 | -0,00065 | -0,0084 | -0,00198 | -0,004509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
14/09/2016 | 34,87 | 41,49 | 147,4 | 31,89 | 0,00359118 | -0,01222 | -0,0228 | -0,00781 | 31,17676 | 30,68778 | 30,36459 | 30,82336 | 0,000898 | -0,00305 | -0,0057 | -0,001952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15/09/2016 | 35,395 | 41,51 | 147,65 | 32,005 | 0,01494375 | 0,000482 | 0,001695 | 0,0036 | 31,53272 | 31,07997 | 31,11769 | 31,17703 | 0,003736 | 0,00012 | 0,000424 | 0,0008999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
16/09/2016 | 34,925 | 40,605 | 146,65 | 31,13 | -0,0133677 | -0,02204 | -0,0068 | -0,02772 | 30,6525 | 30,38772 | 30,8546 | 30,2157 | -0,00334 | -0,00551 | -0,0017 | -0,00693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
19/09/2016 | 35,375 | 41,685 | 149,05 | 31,26 | 0,01280247 | 0,02625 | 0,016233 | 0,004167 | 31,46526 | 31,89126 | 31,5734 | 31,19473 | 0,003201 | 0,006563 | 0,004058 | 0,0010418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
20/09/2016 | 35,275 | 41,46 | 150,05 | 31,065 | -0,0028308 | -0,00541 | 0,006687 | -0,00626 | 30,97719 | 30,89732 | 31,27342 | 30,87122 | -0,00071 | -0,00135 | 0,001672 | -0,001564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The result would be something like this : | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<colgroup><col span="3"><col><col></colgroup><tbody> </tbody> |
<colgroup><col><col><col><col><col span="2"><col><col span="12"><col><col></colgroup><tbody>
</tbody>
Thanks in advance !