Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

for and next loops

ResolvedVersion 2007

Tracey has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

For and Next loops

Hi

We have done a lot of For and Next loops where the looping variable is a series of numbers, eg:

For intName = 1 to 10

Can you set up this looping with non-sequential numbers, or with text? Or can you refer to a list in another location?

eg For dateMonth=Jan,Feb,Mar etc

eg For strName=each of the values on rows 2 to 8 in column 3 on the sheet "List page"?


Thanks

Tracey

RE: For and Next loops

Hi Tracey,

Thank you for your question.

Here is a line of code that will allow non sequential numbers:

For I = 0 to 100 step 2 - step 2 meaning every other number

On the advanced course we cover this and we also cover arrays which may help you.

I hope this has answered your question.

Regards,

Simon

Tue 23 Jun 2009: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Repeat action

The F4 key will usually repeat your last action. e.g. delete a row, then select another row and press F4 to delete again.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.