Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using the following statement:
For Each Cell In Range("D3:J23") I want the range in the For Next statement to move 8 colums to th right and run again. Same row numbers. I need this to happen 20 times. Then I want to increase each If Range value by 1 each time it loops Same column numbers. This is also 20 times.To avoid writing out lik this: If Range("I29").Value = Range("I26") And Cell.Value "" An Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("I30").Value = Range("I27") And Cell.Value "" An Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("H29").Value = Range("H26") And Cell.Value "" An Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") If Range("H30").Value = Range("H27") And Cell.Value "" An Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") etc. Thanks Ji -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim
You could try something like dim i as integer dim cl as range for i = 0 to 7 for each cl in Range("D3:J23").offset(0,i).cells 'do your stuff next cl next i I'm not totally sure what you are after but I think offset may do what you want, there may be better ways cheers simon -----Original Message----- I'm using the following statement: For Each Cell In Range("D3:J23") I want the range in the For Next statement to move 8 colums to the right and run again. Same row numbers. I need this to happen 20 times. Then I want to increase each If Range value by 1 each time it loops. Same column numbers. This is also 20 times.To avoid writing out like this: If Range("I29").Value = Range("I26") And Cell.Value "" And Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("I30").Value = Range("I27") And Cell.Value "" And Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("H29").Value = Range("H26") And Cell.Value "" And Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") If Range("H30").Value = Range("H27") And Cell.Value "" And Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") etc. Thanks Jim --- Message posted from http://www.ExcelForum.com/ . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Simon, but I could not get it to work. It seems like it might b
the right idea, but I'm not sure. Ji -- Message posted from http://www.ExcelForum.com |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Something like? For iCol = 4 To 164 Step 8 For Each Cell In Range(Cells(iCol,3),Cells(iCol+7,23) If Cells(29, iCol+6).Value = Cells(26, iCol+6) And _ Cell.Value "" And _ Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") 'etc Next Cell Next iCol -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "hotherps " wrote in message ... I'm using the following statement: For Each Cell In Range("D3:J23") I want the range in the For Next statement to move 8 colums to the right and run again. Same row numbers. I need this to happen 20 times. Then I want to increase each If Range value by 1 each time it loops. Same column numbers. This is also 20 times.To avoid writing out like this: If Range("I29").Value = Range("I26") And Cell.Value "" And Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("I30").Value = Range("I27") And Cell.Value "" And Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("H29").Value = Range("H26") And Cell.Value "" And Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") If Range("H30").Value = Range("H27") And Cell.Value "" And Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") etc. Thanks Jim --- Message posted from http://www.ExcelForum.com/ |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm probably not explaining myself well enough. Here is a piece of th
actual code: For Each Cell In Range("D3:J23") If Range("I29").Value = Range("I26") And Cell.Value "" An Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("H29").Value = Range("H26") And Cell.Value "" An Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") If Range("G29").Value = Range("G26") And Cell.Value "" An Cells(Cell.Row, "AM") = "x" Then _ Cell.Value = Range("AM1") If Range("J29").Value = Range("J26") And Cell.Value "" An Cells(Cell.Row, "AP") = "x" Then _ Cell.Value = Range("AP1") If Range("F29").Value = Range("F26") And Cell.Value "" An Cells(Cell.Row, "AL") = "x" Then _ Cell.Value = Range("AL1") Next For Each Cell In Range("K3:Q23") If Range("I30").Value = Range("I27") And Cell.Value "" An Cells(Cell.Row, "AO") = "x" Then _ Cell.Value = Range("AO1") If Range("H30").Value = Range("H27") And Cell.Value "" An Cells(Cell.Row, "AN") = "x" Then _ Cell.Value = Range("AN1") If Range("G30").Value = Range("G27") And Cell.Value "" An Cells(Cell.Row, "AM") = "x" Then _ Cell.Value = Range("AM1") If Range("J30").Value = Range("J27") And Cell.Value "" An Cells(Cell.Row, "AP") = "x" Then _ Cell.Value = Range("AP1") If Range("F30").Value = Range("F27") And Cell.Value "" An Cells(Cell.Row, "AL") = "x" Then _ Cell.Value = Range("AL1") I'm sure you can see how redundant it is. There are additional range for both the "For Each" Statements and the "If Range" statments (abou 20 of each) Thanks agai -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Averaging times that are not in a range | Excel Worksheet Functions | |||
change range for multiple charts | Charts and Charting in Excel | |||
Plotting multiple times against one date succesively for multiple | Charts and Charting in Excel | |||
how many times a specific value is in a range...? | Excel Worksheet Functions | |||
Count how many times a certain value is in a certain range | Excel Discussion (Misc queries) |