montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 986
- Office Version
- 2010
- Platform
- Windows
Hello, everyone.
I am trying to check an entire dynamic array with some conditions.
I have a six months data on B2: G
the conditions are:
IF B5 < B4 and B3 < B5 then ( B3 - 4) else (B3 + 1)
and the same for the others columns, C,D,E,F and G
I did only the if statements code, what I am trying to figure out is
How to loop in order to go to the LastRow
and every time the code will go one cell down at the time
the sensitive part for me here is that the condition are NOT EQUAL on
every COLUMN, you will see what I mean with the code I am loading
Thanks for reading this post, I really understand how valuable is your time.
Here you can see, on
Column B the condition is c= c - 4 and C + 1, but on Column
C change d = d - 6 and d = d + 3
column D condition is si = si - 8 and si = si +5
column E condition is ........["here I know you can handle different so as a reference, I am providing a sort of names for this part of the code, but you will named anyway you want, please"]
E variable = variable - 10 and variable = variable + 7
F variable = variable - 12 and variable = variable + 9
G variable = variable - 14 and variable = variable + 11
Thanks again
I am trying to check an entire dynamic array with some conditions.
I have a six months data on B2: G
the conditions are:
IF B5 < B4 and B3 < B5 then ( B3 - 4) else (B3 + 1)
and the same for the others columns, C,D,E,F and G
I did only the if statements code, what I am trying to figure out is
How to loop in order to go to the LastRow
and every time the code will go one cell down at the time
the sensitive part for me here is that the condition are NOT EQUAL on
every COLUMN, you will see what I mean with the code I am loading
Thanks for reading this post, I really understand how valuable is your time.
VBA Code:
Sub sat()
Dim x As Long, y As Long, c As Long
c = Range("b3").Value: y = Range("b4").Value: x = Range("b5").Value
Range("i2").ClearContents
If x < y And c < x Then
c = c - 4
Else
c = c + 1
Range("i2").Value = c
End If
End Sub
Sub mon()
Dim k As Long, m As Long, d As Long
d = Range("c3").Value: m = Range("c4").Value: k = Range("c5").Value
Range("j2").ClearContents
If k < m And d < k Then
d = d - 6
Else
d = d + 3
Range("j2").Value = d
End If
End Sub
Sub wed()
Dim h As Long, z As Long, si As Long
si = Range("d3").Value: z = Range("d4").Value: h = Range("d5").Value
Range("k2").ClearContents
If h < z And si < h Then
si = si - 8
Else
si = si + 5
Range("k2").Value = si
End If
End Sub
Column B the condition is c= c - 4 and C + 1, but on Column
C change d = d - 6 and d = d + 3
column D condition is si = si - 8 and si = si +5
column E condition is ........["here I know you can handle different so as a reference, I am providing a sort of names for this part of the code, but you will named anyway you want, please"]
E variable = variable - 10 and variable = variable + 7
F variable = variable - 12 and variable = variable + 9
G variable = variable - 14 and variable = variable + 11
Thanks again