VBA increment value until a condition is met

RPM7

Board Regular
Joined
Nov 28, 2007
Messages
191
Would anyone be able to help me with the following VBA?
I've no idea of how to do it.

If D15 < K15, then increment Y15 value+1 (This would need to loop until the condition is met)
Then go to next row and check the same.

This would have to apply to rows 15 to 44

Thanks
 
Thanks for the update @footoo, unfortunately the updated macro didn't work.
I've been using the original macro you sent and to be honest, it's actually working great for me.
I like being able to monitor the increments.

I have tried modifying your macro on another worksheet to include an 'OR' statement, but it tends to continue incrementing each row regardless of the conditions being met.
It only stops when every row has met the 3 conditions.

Do you know what I might be doing wrong?


VBA Code:
Sub BSJF_increment()

[AA15:AA44] = Evaluate("IFERROR ( IF ( or ( W15:X44<K13 , BJ15:BJ44<BH15:BH44 , BK15:BK44<BI15:BI44 ) , (AA15:AA44)+1 , AA15:AA44) , """")")

End Sub
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
What do want from this :
VBA Code:
 W15:X44<K13
Does it mean any cell in columns W:X of the same row less than cell K13 ?
 
Upvote 0
What do want from this :
VBA Code:
 W15:X44<K13
Does it mean any cell in columns W:X of the same row less than cell K13 ?
Yes, K13 is a fixed value.

It works with the following:
VBA Code:
[AA15:AA44] = Evaluate("IFERROR ( IF ( W15:X44<K13 , (AA15:AA44)+1 , AA15:AA44) , """")")


I can get also the following two vba examples work independently, but when I try to combine two or more conditions with an "OR" statement, I have issues.

Code:
[AA15:AA44] = Evaluate("IFERROR ( IF ( BJ15:BJ44<BH15:BH44 , (AA15:AA44)+1 , AA15:AA44) , """")")

Code:
[AA15:AA44] = Evaluate("IFERROR ( IF ( BK15:BK44<BI15:BI44 , (AA15:AA44)+1 , AA15:AA44) , """")")
 
Upvote 0
Try this :
VBA Code:
[AA15:AA44] = Evaluate("IFERROR(IF((W15:W44<$K$13)+(X15:X44<$K13)+(BJ15:BJ44<BH15:BH44)+(BK15:BK44<BI15:BI44),(AA15:AA44)+1,AA15:AA44),"""")")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,935
Messages
6,175,496
Members
452,649
Latest member
mr_bhavesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top