for and next loops
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » For and Next loops

For and Next loops

resolvedResolved · Low Priority · Version 2007

replyReply Fri 12 Jun 2009, 16:18Delegate Tracey said...

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

For upcoming training course dates see: Pricing & availability

replyReply Wed 17 Jun 2009, 13:53Trainer Simon said...

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.

 

Please browse our web site to find out more about
excel training courses and other Microsoft training courses.

Excel tip:

Brighten up your Excel 2010 Spreadsheet by changing the colours of the gridlines

Excel 2010 allows you to change the colour of grid lines instead of keeping them in boring black.

Select the File tab on the Ribbon, click Options, click Advanced, scroll down to ''Display options for this worksheet.'' Next to ''Gridline colour,'' choose your favourite colour, then once you've done this, click OK. Easy!

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard