Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Using code to automate "h:mm" | Excel Discussion (Misc queries) | |||
use VB code IF to automate filling in 11 columns | Excel Discussion (Misc queries) | |||
Automate without add-ins | Excel Discussion (Misc queries) | |||
Automate PDF file creation in Excel code | Excel Programming | |||
VBA Code to automate "Save As" | Excel Programming |