ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Loop (https://www.excelbanter.com/excel-programming/431254-simple-loop.html)

John

Simple Loop
 
I have data in I4:I18. If the value is greater than zero I would like to
check if the value in V & activerow (ex: V4) is greater than I & activerow.
If so, do command and keep checking the remaining rows.

Mike H

Simple Loop
 
John,

Try this

Sub sonic()
For Each c In Range("I4:I18")
If IsNumeric(c.Value) And c.Value 0 And c.Value c.Offset(, 13).Value
Then
'Do something"
End If
Next
End Sub

Mike

"John" wrote:

I have data in I4:I18. If the value is greater than zero I would like to
check if the value in V & activerow (ex: V4) is greater than I & activerow.
If so, do command and keep checking the remaining rows.


Jacob Skaria

Simple Loop
 
Try

Sub Macro()
For Each c In Range("I4:I18").Rows
If Range("V" & c.Row) <= c.Value Then
'Do somthing. Number in V less than I
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

I have data in I4:I18. If the value is greater than zero I would like to
check if the value in V & activerow (ex: V4) is greater than I & activerow.
If so, do command and keep checking the remaining rows.


John

Simple Loop
 
I am getting the command run (the do something part) run 16 times... How do I
check that row once and then move to the next row?

"Jacob Skaria" wrote:

Try

Sub Macro()
For Each c In Range("I4:I18").Rows
If Range("V" & c.Row) <= c.Value Then
'Do somthing. Number in V less than I
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

I have data in I4:I18. If the value is greater than zero I would like to
check if the value in V & activerow (ex: V4) is greater than I & activerow.
If so, do command and keep checking the remaining rows.


John

Simple Loop
 
nevermind got it...

"John" wrote:

I am getting the command run (the do something part) run 16 times... How do I
check that row once and then move to the next row?

"Jacob Skaria" wrote:

Try

Sub Macro()
For Each c In Range("I4:I18").Rows
If Range("V" & c.Row) <= c.Value Then
'Do somthing. Number in V less than I
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

I have data in I4:I18. If the value is greater than zero I would like to
check if the value in V & activerow (ex: V4) is greater than I & activerow.
If so, do command and keep checking the remaining rows.



All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com