Range of columns

H

hotherps

I'm trying to finish this up but I'm having a problem with the oute
loops.

For K = 305 To 316 '
For t = 319 To 330 '
For Each cell In Range("G11:n298") Step 8 '
c = Array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
For i = 0 To 11
If Cells(t, c(i)).Value - 1 >= Cells(K, c(i)) And cell.Value >= 1 An
_
Cells(cell.Row, c(i) + 97) = "x" Then
cell.Value = Cells(9, c(i) + 97)
End If
Next i
Next cell
Next K '
Next t '

What I'm trying to do is after the array completes I want to incremen
K by 1 and t by 1 and then step over to the next 8 columns("O11:V298"
and run the code again.

I have comments on the end of the lines that are not working.
Thank
 
P

pikus

foo = -1
For K = 305 To 316
t = K + 14
foo = foo + 8
For Each cell In Range(.Cells(11, foo), .Cells(298, foo + 7)) Step 8

blahblahblah

Next K

- piku
 
H

hotherps

Thanks
I hate to ask but, I'm getting an error. The line with the "For Each
statment is colored red.

I think I pasted it correctly?

foo = -1
For K = 305 To 316
t = K + 14
foo = foo + 8
For Each cell In Range(.Cells(11, foo), (.Cells(298, foo + 7)) Step 8
c = Array(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
For i = 0 To 11
If Cells(t, c(i)).Value - 1 >= Cells(K, c(i)) And cell.Value >= 1 An
_
Cells(cell.Row, c(i) + 97) = "x" Then
cell.Value = Cells(9, c(i) + 97)
End If
Next i
Next cell
Next
 
P

pikus

Hey,
I only looked at the lines that were broken before, but now that I'
looking a little more closely, I think you're going about this the lon
way. Please describe to me what it is you're doing in greater detail.
Thanks. - piku
 
B

Bob Phillips

Try

For Each cell In Range(.Cells(11, foo), .Cells(298, foo + 7)) Step 8


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Dana DeLouis

c = Array(7, 8, 9, 10, 11, ...

You keep generating this same array with each loop. I would move this to
the very beginning so as to make it only once.

Actually, it appears you could drop the array, maybe something along this
line:
For c = 7 To 18
If Cells(t, c).Value - 1 >= Cells(K, c) And ...etc

Just an idea.
Dana DeLouis
 
H

hotherps

Thanks Bob but isn't your line exactly the same as what Pikus has?

I got the same error :Expected end of statment

???

Thanks Dana, I guess that could work, but I have some time constraint
at the moment. Maybe I can try it later
 
P

pikus

Hey again. It's funny to me that this is about scheduling. I am, by
trade, a workforce management analyst. I'll be taking this home with
me. I sent you my e-mail address in a private message, e-mail me and I
can send you the file as soon as it's complete. - pikus
 
B

Bob Phillips

No I took out an extraneous ( which looked like the error to me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
H

hotherps

Yes i do see the difference now Bob, but the text still goes to a red
font and I get a syntax error message.

Thanks for the post
 

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