Increment outer loops

H

hotherps

I'm having a problem with the values K and T

For K = 305 To 316
For t = 319 To 330

For Each cell In Range("G11:N298")
c = Array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
For i = 0 To 13
If Cells(t, c(i)).Value - 1 >= Cells(K, c(i)) And
Cells(cell.Row, c(i) + 97) = "x" Then
cell.Value = Cells(9, c(i) + 97)
End If
Next i
Next

After the array and the rest of the code has finished I want t
increase the value of K by one and the value of T by one. No matte
where I put it I get an error. What am I missing?
Thank
 
K

Ken

Will this work for you?

For K = 305 To 316
For Each cell In Range("G11:N298")
c = Array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20)
For i = 0 To 13
If Cells(K + 14, c(i)).Value - 1 >= Cells(K, c
(i)) And Cells(cell.Row, c(i) + 97) = "x" Then
cell.Value = Cells(9, c(i) + 97)
End If
Next i
Next K
 
T

Tom Ogilvy

For K = 305 To 316
For t = 319 To 330

For Each cell In Range("G11:N298")
c = Array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
For i = 0 To 13
If Cells(t, c(i)).Value - 1 >= Cells(K, c(i)) And _
Cells(cell.Row, c(i) + 97) = "x" Then
cell.Value = Cells(9, c(i) + 97)
End If
Next i
Next cell
Next t
Next K
 
H

hotherps

I thought I had tried that? But I must have been missing something. You
code ran fine.

I have one more question if you don't mind.

I have twelve ranges to run this code through. Each time K and
increment, it should move to the next range. It is in steps of 8 and i
starts in column 7 and ends in column 102

Is there an easy way to incorporate this?

Thanks again
 
H

hotherps

That worked fine, I thought I had it that way at one point but I gues
not.

One more quick question if you don't mind. I would like to run the cod
through 12 ranges each time incrementinh T and K would this be difficul
to incorporate?

The columns would be from 7 to 102 with a step of 8

I'm not sure how to phrase it?

Thanks agai
 
K

Ken

Are you referring to my code or to Tom's?
We had different approaches to your question and mine was
missing a "Next cell" line of code.
So, I was guessing that, if it ran fine, it was Tom's.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top