Excel and Vba Problem Set
Excel and Vba Problem Set
(Total: 20 Marks)
a) Record a macro which inserts the following table anywhere on the worksheet. Name the Macro
“Item Details”. Give it a suitable description. (Formatting should be close to the given example if not
exactly the same).
b) Insert a button on the worksheet which can run your “Item Details” Macro. Rename the button as
“Insert Item Details”. Then using the button, populate your worksheet with the tables as shown
below.
Task 2 (3+5 Marks):
Move to the “PNL” worksheet.
a) Record a Macro named “ProfitandLoss” which inserts the following on the top right of a
worksheet only. Give it a suitable description. (Formatting should be close to the given example
if not exactly the same).
b) Look at the data in the “Data Entered” worksheet. We will now use that to populate our profit
and loss statement using macros (assuming that the data entered, and profit and loss statement
are always given in these same cells).
Record a macro named “DataFill” which inputs data from “Data Entered” worksheet (through
referencing) the following in the profit and loss statement:
Sum of sales in D6
Sum of Cogs in D7
Sales-COGS in D9
Fixed Expenses in D12-D15
Sum of fixed expenses in D16
Gross Profit – Sum of fixed expenses in D17
The result of this macro should be a fully populated profit and loss statement.
a) Record a Macro named “Monthly_Sales” which inserts the following table on the top right of a
worksheet only. Give it a suitable description. (Formatting should be close to the given example
if not exactly the same).
b) Create a new workbook. Label that as “Rollnumber – Part2” and save it as an .xlsx file (we don’t
want to retain any macros in this file but we do wish to run a macro here from our first
workbook).
Run the “Monthly_Sales” macro to create the monthly sales worksheet in this workbook. Then
save the progress and close this workbook. Submit it along with the main workbook.
Task 4 (3 Marks):
Move to the “Model” worksheet.
Demand for crisps changes based on the price set. This eventually affects the total sales for crisps. The
basic model and formulas are set in the worksheet.
Use the right Form Control Button and link it to the crisp’s price such that:
Observe the changes in demand and sales with change in prices when you click the button.