Microsoft Developer
Looping over collections exercise
Average difficulty

This Microsoft Developer LOOPING OVER COLLECTIONS exercise is provided to allow potential course delegates to assess their suitability for the Wise Owl EXCEL VISUAL BASIC course only, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Exercise: Elmer elephant - random colours

A full answer to this exercise is provided as part of the training course!

1) Download the files needed to start this exercise: exercise-568.zip (and click here if you experience any problems unzipping this file after downloading it).
2) When you open the file above, you should see Elmer the elephant:
Exercise screen-shot 1157 Elmer is a playful but responsible elephant - here seen with his duck
3) Create a macro to colour (say) A1:J10 at the top left of the worksheet in random colours from 1 to 32.  Here is what the worksheet should look like after you run your macro:
Exercise screen-shot 1158 This is the effect you should get
Training exercise hint Use a line which sets the Interior.ColorIndex property of each cell in the range to Int(math.rnd()*32)- and ask your trainer to explain this if it doesn't make sense!
4) If you get the macro working, try nesting it inside another loop so that the pattern is continually redrawn.
5) Save and close this workbook before you do serious damage to your eyes!

Thank you for showing an interest in this Excel Visual Basic training course! As mentioned above, full answers to this and other exercises are provided on the course. On all Wise Owl scheduled courses delegates can take away these model answers (together with their own efforts!) on a free USB stick.

All content copyright Wise Owl Business Solutions Ltd 2008.  All rights reserved..