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 ==> | Excel VBA Macros (52 exercises) |
Topic ==> | Looping over collections (11 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.
Open the file called Mortgage calculator.xlsm and enter some values at the top of the Inputs sheet.
Enter the amount you want to borrow and how many years you'd like to repay the loan. This might buy a small shed in London ...
Create a subroutine which begins by copying the values you have entered into the appropriate cells on the Calculator sheet:
Copy the values into these coloured cells on the Calculator sheet.
Add code to create a new workbook. You'll find it useful to capture a reference to this workbook in a variable.
Dim OtherWorkbook As Workbook
Set OtherWorkbook = Workbooks.Add
Add a For Each loop which loops through the list of mortgage deals on the Inputs sheet. Copy the details of each deal into the appropriate cells on the Calculations sheet.
Copy the details for each deal into the pale yellow cells.
After setting the details for a deal within the loop, copy the Calculations worksheet so that it becomes the first worksheet in the workbook you created earlier. Use the code below to guide you:
'copy a worksheet to another workbook
wsCalculator.Copy _
Before:=OtherWorkbook.Worksheets(1)
Still within the For Each loop, change the name of the copied worksheet to match the reference number of the deal.
Your worksheet names should look something like this.
After the loop has finished, add code which deletes Sheet1 from the output workbook.
To prevent a warning message appearing when you do this, add this line before you delete the worksheet:
Application.DisplayAlerts = False
Add code which saves the output workbook and then closes it.
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.