montecarlo2012
Wellknown Member
 Joined
 Jan 26, 2011
 Messages
 634
 Office Version

 2010
 Platform

 Windows
Hi, I am trying to loop through a dynamic array B2:G and results on M:V and this is what I tryed.
The results I got from here "all wrong"
Please any of you can help me here.
VBA Code:
Sub Monte_carlo()
With Range("M2:M" & Cells(Rows.Count, "B").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[11]="""","""",IF(MOD(RC[11],12)=0,""E"",""P""))"
.Value = .Value
End With
With Range("N2:N" & Cells(Rows.Count, "C").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[12]="""","""",IF(MOD(RC[12],13)=0,""E"",""P""))"
.Value = .Value
End With
With Range("O2:O" & Cells(Rows.Count, "D").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[13]="""","""",IF(MOD(RC[13],14)=0,""E"",""P""))"
.Value = .Value
End With
With Range("P2:P" & Cells(Rows.Count, "E").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[14]="""","""",IF(MOD(RC[14],15)=0,""E"",""P""))"
.Value = .Value
End With
With Range("Q2:Q" & Cells(Rows.Count, "F").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[15]="""","""",IF(MOD(RC[15],16)=0,""E"",""P""))"
.Value = .Value
End With
With Range("R2:R" & Cells(Rows.Count, "G").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[16]="""","""",IF(MOD(RC[16],17)=0,""E"",""P""))"
.Value = .Value
End With
With Range("S2:S" & Cells(Rows.Count, "H").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[17]="""","""",IF(MOD(RC[17],18)=0,""E"",""P""))"
.Value = .Value
End With
With Range("T2:T" & Cells(Rows.Count, "I").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[18]="""","""",IF(MOD(RC[18],19)=0,""E"",""P""))"
.Value = .Value
End With
With Range("U2:U" & Cells(Rows.Count, "J").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[19]="""","""",IF(MOD(RC[19],20)=0,""E"",""P""))"
.Value = .Value
End With
With Range("V2:V" & Cells(Rows.Count, "K").End(xlUp).Row)
.FormulaR1C1 = "=IF(RC[20]="""","""",IF(MOD(RC[20],21)=0,""E"",""P""))"
.Value = .Value
End With
End Sub
Please any of you can help me here.