Assignment 2 2025
Unique #:
Due Date: 12 June 2025
Detailed solutions, explanations, workings
and references.
+27 81 278 3372
, QUESTION 1
Question a.
Simple Step-by-Step Guide to Open Your Excel File and Copy the VBA Code
Into It:
How to Open the Bookings File and Add VBA Code
Step 1: Open the Excel File
1. Open Excel on your computer.
2. Click File > Open and browse to the file named:
Bookings_Feb_2024.xlsx
3. Once it opens, click File > Save As and save it as:
StudentNumber_Surname_Q1.xlsm
4. ✅Make sure to choose Excel Macro-Enabled Workbook (*.xlsm) as the file type.
Step 2: Open the VBA Editor
1. Press Alt + F11 on your keyboard. This opens the VBA Editor.
2. In the left panel (Project Explorer), right-click on VBAProject
(YourWorkbookName).
3. Click Insert > Module. A blank code window will appear.
Step 3: Copy and Paste the VBA Code
1. Copy the function and sub-procedure code provided.
Example function (Question 1a):
' Student Number: [Your Student Number]
' Function to calculate ticket revenue based on destination and passenger counts
Function CalculateTicketRevenue(destination As String, numAdults As Integer, numChildren
As Integer) As Double
Const CPT_ADULT As Double = 1800
Const CPT_CHILD As Double = 1350
Const DBN_ADULT As Double = 1500
Const DBN_CHILD As Double = 1125
Const WDH_ADULT As Double = 3500
Const WDH_CHILD As Double = 2625
If destination = "Cape Town" Then
Varsity Cube 2025 +27 81 278 3372