Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Advanced VBA (28 exercises) |
Topic ==> | Working with shapes (3 exercises) |
Level ==> | Harder than average |
Subject ==> | VBA training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
It's easiest to do this exercise in two parts: first draw the starting grid, then run the race.
To start the race, first create a new workbook, and write a macro (using the images in the above folder) to draw autoshapes at the start of the first 4 rows of a spreadsheet:
The cars are 40 points wide, 30 points high and begin 20 points in from the left of their cells and 10 points down from the top. The ColumnWidth of each column is 15, and the RowHeight of each row is 50.
The easiest way to draw the cars is to draw a basic rectangular autoshape (type 1), then run a line of code like this to apply a picture to it:
Car.Fill.UserPicture "D:\exercises\car1.jpg"
When you've got the grid set up, it's time to run the race! Write a second macro to loop until a car has won (ie reached column H).
Clicking on the message box should run the next move, which should advance one of the four cars (chosen at random) one cell. The answer uses the expression Int(Math.Rnd() * 4) + 1 to choose a random car number.
Here's what your screen might look like after running a race:
This time the fourth (white) car won - you should announce this fact with a final message.
When you've got this working, save this workbook as Chequered flag, then close it down.
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.