Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change range multiple times

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Change range multiple times

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change range multiple times

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change range multiple times


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change range multiple times

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Averaging times that are not in a range Nancy D Excel Worksheet Functions 3 April 20th 10 05:19 PM
change range for multiple charts Yossi evenzur[_2_] Charts and Charting in Excel 2 December 9th 09 02:30 AM
Plotting multiple times against one date succesively for multiple Mal[_2_] Charts and Charting in Excel 1 August 25th 09 08:49 PM
how many times a specific value is in a range...? Dan B Excel Worksheet Functions 2 November 8th 06 10:45 PM
Count how many times a certain value is in a certain range [email protected] Excel Discussion (Misc queries) 1 September 5th 06 10:42 PM


All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"