Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default forgotten variations of loop


Hi i have always used the following loop statement in my code.
Do
''stuff
'' have a range setup
set rng = rng.offset(1,0)

Loop until rng = (some value such as 2004)

I know that somehow you can loop until you find a certain value e.g
2003, perform the loop once more and then exit loop. This would avoid
using the 'until' part and would benefit me more as not all of my
sheets contain cells with 2004 in them.

Just to give you a bit further background the loop copies and pastes
raw data in certain columns until it reaches 2004 which is forecasted,
however not all sheets/ranges need to contain forecasted data and thus
have a column entitled 2004!!


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=543676

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default forgotten variations of loop

You can condition on the current cell at the top of the loop so that all 2003
gets processed and it quits before it processes 2004

Do while rng < 2004
set rng = rng.offset(1,0)
Loop

However, your original code would also perform that way. The next cell to
be processed is checked at the bottom of the loop, so if that were 2004 it
would quit.


Perhaps you could be more specific about this particular situation and what
you want to do.
--
Regards,
Tom Ogilvy



"cereldine" wrote:


Hi i have always used the following loop statement in my code.
Do
''stuff
'' have a range setup
set rng = rng.offset(1,0)

Loop until rng = (some value such as 2004)

I know that somehow you can loop until you find a certain value e.g
2003, perform the loop once more and then exit loop. This would avoid
using the 'until' part and would benefit me more as not all of my
sheets contain cells with 2004 in them.

Just to give you a bit further background the loop copies and pastes
raw data in certain columns until it reaches 2004 which is forecasted,
however not all sheets/ranges need to contain forecasted data and thus
have a column entitled 2004!!


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=543676


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
matching 1 to 1 and 1 with variations... srmyers1 Excel Worksheet Functions 3 November 6th 09 05:46 PM
Many possible variations art Excel Worksheet Functions 0 May 7th 09 11:07 PM
graphs with multiple variations q.m. hollemans Excel Discussion (Misc queries) 0 July 10th 07 01:20 PM
Variations on Sumif EG Excel Worksheet Functions 3 April 23rd 07 03:14 PM
number variations aint much cop Excel Discussion (Misc queries) 3 July 16th 05 01:40 PM


All times are GMT +1. The time now is 05:00 AM.

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

About Us

"It's about Microsoft Excel"