|
-
Oct 6th, 2010, 09:56 AM
#1
Thread Starter
Junior Member
Loop with multiple critiria
I’m having problems with a loop that copies rows to a different sheet if a condition is met. The loop works for the first condition but doesn’t seem to move to the next condition or part of the loop. Whatever I do either turns into an endless loop or is missing part of the code to execute. The following is a sample of the code I’m using with two of the seven conditions I want it to find and copy to another sheet. Thanks for any help.
'loop to Repair list
'Pressure
Set i = Sheets("Bad")
Set e = Sheets("Repair List")
Dim d
Dim j
d = 1
j = 2
Do Until IsEmpty(i.Range("A" & j))
If i.Range("D" & j).Value = 0 Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
'Water Level
Do
If i.Range("E" & j).Value < 11.1 Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
End If
j = j + 1
Loop
End Sub
-
Oct 6th, 2010, 10:49 AM
#2
Re: Loop with multiple critiria
The second Do isn't doing until something.
If your first case, you are saying
Code:
Do Until IsEmpty(i.Range("A" & j))
In your second, you are just saying "Do" - Do what until when?
-
Oct 7th, 2010, 08:14 AM
#3
Thread Starter
Junior Member
Re: Loop with multiple critiria
In the second case I want it to Do -
If i.Range("E" & j).Value < 11.1 Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value
Until IsEmpty(i.Range("A" & j))
Just like in the first case.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|