ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automate this code (https://www.excelbanter.com/excel-programming/304715-automate-code.html)

hotherps[_81_]

Automate this code
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Automate this code
 
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?)

--
Regards,
Tom Ogilvy

"hotherps " wrote in message
...
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 "" And
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 about
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
Thanks


---
Message posted from http://www.ExcelForum.com/




hotherps[_82_]

Automate this code
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Automate this code
 
Looks like you have an active thread going on this already.

--
Regards,
Tom Ogilvy

"hotherps " wrote in message
...
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 I
listed id just a small part of the file. What I would like to do is
loop through 8 columns at a time from top D11 to Bottom CX125 , only
advancing 8 colums to hthe right everytime the loop completes.

It's really not working that well.

Thanks for your help.


---
Message posted from http://www.ExcelForum.com/




hotherps[_83_]

Automate this code
 
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

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:43 PM.

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