Automate this code

H

hotherps

I have the following code:
For Each cell In Range("G11:O125")
c = Array(11, 10, 9, 8, 7)
For i = 0 To 4
If Cells(356, c(i)).Value >= Cells(305, c(i)) And cell.Value > "" An
Cells(cell.Row, c(i) + 97) = "x" Then _
cell.Value = Cells(9, c(i) + 97)
Next i
Next

On the If statement I need to offset one cell down in both ranges abou
50 rows. i.e. 357,358 : 306,307 etc.

As opposed to doing this:

If Cells(356, c(i)).Value >= Cells(305, c(i)) And cell.Value
If Cells(357, c(i)).Value >= Cells(306, c(i)) And cell.Value
If Cells(358, c(i)).Value >= Cells(307, c(i)) And cell.Value
Thank
 
T

Tom Ogilvy

do you want to do all three comparisons in the if statement or do you want
to do one of them for each pass through the loop, incrementing as you loop.
(if so, why only 3 ranges when the loop loops 5 times?)
 
H

hotherps

Thanks Tom, I replied to your post but I guess it did not take?

Yes it has to meet all three conditions before it loops. The range
listed id just a small part of the file. What I would like to do i
loop through 8 columns at a time from top D11 to Bottom CX125 , onl
advancing 8 colums to hthe right everytime the loop completes.

It's really not working that well.

Thanks for your help
 
H

hotherps

Yes Tom I noticed, I think I started that by accident. Anyway Here i
what I have at the moment:

For Each cell In Range("G11:N125")
c = Array(15, 14, 13, 12, 11, 10, 9, 8, 7)
For i = 0 To 8
If Cells(356, c(i)).Value - 1 >= Cells(305, c(i)) And cell.Value > "
And Cells(cell.Row, c(i) + 97) = "x" Then _
cell.Value = Cells(9, c(i) + 97)
Next i
Next

The problem is that if the reference to Cells 356 and 305 is true th
code runs it's entire length. I need it to stop and check the cells on
row at a time down to
Cells 402 and 352
Thank
 

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