Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLS ANSWER COMPLETELY IN Excel VBA Write a macro that processes the following sales data (your final code should work with data that have any

PLS ANSWER COMPLETELY IN Excel VBA

Write a macro that processes the following sales data (your final code should work with data that have any number of products, different number of price breaks, different quantities for a price break, different % of extra discount, different amount for a total discount and a list with more or fewer clients).

It can be safely assumed that the data in the Products worksheet has the word Product in an anchor cell (e.g., cell A4) and the Extra Discount and If more than values are two columns to the right from the last column with price breaks. Similarly, the Total Ordered, Total Amount and Total Amount (with extra discount) columns are after skipping one column (as shown in the example below). In the worksheet named Products the following example data are given:

Thus, for example if a customer orders between 100 and 499 units of Gadget1 the unit price is $10.20 for each unit, not only for the units in excess of 100. Each customer can order different quantities of each of the gadgets. If the total dollar amount ordered by a customer exceeds $25,000.00 (number specified in cell G7 for this example three rows down from the anchor cell (i.e., cell A4 in this example) and two columns to the right of the last column with price breaks), then the customer receives an extra discount of 5% (number in cell G5 in this example one row down from the anchor cell and two columns to the right of the last column with price breaks) of the total purchase. Note that headers in this Products worksheet are pre-specified.

The worksheet named Clients has a list of 10 clients (it can have more or fewer) with different quantities of products ordered. The program will populate the columns to the right of the last column with data (including headers). For example, the Amount Before Extra Discount paid by the last client for Gadget1 is $9,311.20 (=1030*$9.04); that is, the amount in cell F14 (in this example) of the clients worksheet would be $9,311.20. The Total Amount in column J in the sum of the Amount Before Extra Discount over all products and depends on the quantities ordered as indicated in the worksheet Products. If, however, the Total Amount of purchase exceeds the if more than in the worksheet Products, ($25,000.00 indicated in cell G7 in this example) then the percent extra discount specified in the worksheet Products (cell G5 in this example) applies in addition to the discounts obtained by the quantity ordered of each gadget (i.e., in this example the 5% discount applies to each unit cost of the gadget bought by the customer). Note that the headers in this worksheet are pre-specified for the Clients, and the

product names but the headers for all other columns have to be appropriately generated and placed through VBA. That is, the cells populated by the program in all the worksheets should be cleaned out every time the program is run and before calculating the new values.

Using the data provided, the macro will calculate the Amount Before Extra Discount for each product, Total Amount before extra discount, Amount After Discount (if any) for each product, and After Discount Total Amount for each client in the worksheet Clients. In the worksheet Products report the number for each product under the Total Ordered header, the Total Amount before the extra discount for each product and the Total Amount (with extra discount) for each product.

(Hint: Initially use cell A4 as anchor cell in the products worksheet and also in the Clients

worksheet. Define range variables for the products and the price breaks and assign the number

of products and the number of price breaks to variables. Assign to variables the extra discount

percentage and the amount required for the extra discount. You may need to use nested For

Next loops to loop through Clients, then through Gadgets and then through Price Breaks. The

loop through Price Breaks may be easier to do going from the highest to the lowest order

quantity for the price break.)

Your code should work if the data are located in worksheets with tab names and anchor cells

that could be different to the names and anchor cells given here. That is, your code will work

even if the anchor cell is different than A4 for the price breaks and different than A4 for the

client list. In addition, your code should work even if the worksheet tab names are different than

Products and Clients. The tab name for worksheets with other product lists and other client

lists and the anchor cells should be read from cells A1 to A4 of a worksheet with tab name

Scenario. image text in transcribedimage text in transcribedimage text in transcribed

A B D E F G H K 1 2 Unit Price for different quantities ordered Minimum Order Quantity to get unit price 3 Total Amount (with extra discount) Total Ordered Total Amount 4 Product 5 Gadget1 6 Gadget2 7 Gadget3 0 $10.25 $12.40 $9.50 100 $10.20 $11.72 $9.00 500 $9.51 $11.42 $8.92 1000 $9.04 $11.14 $8.45 Extra Discount 5.00% If more than $25,000.00 E F G H J K M N O P Amount Before Extra Discount Gadget1 Gadget2 Gadget3 Total Amount Amount After Discount (if any) Gadgeti Gadget2 Gadget3 After Discount Total Amount B D 1 2 3 Quantities ordered 4 Clients Gadget1 Gadget2 Gadget3 5 1 122 1059 1163 6 2 1252 250 385 7 3 898 58 347 8 4 476 1160 840 9 5 981 861 884 10 6 617 1176 1290 11 7 805 334 1233 12 8 1084 249 847 13 9 1404 949 776 14 10 1030 1080 1476 The final answer for this particular set of numbers should be: A B C E F G H K 1 2 Unit Price for different quantities ordered Minimum Order Quantity to get unit price 3 0 4 Product 5 Gadget1 6 Gadget2 7 Gadget3 100 $10.20 $11.72 $9.00 $10.25 $12.40 $9.50 500 $9.51 $11.42 $8.92 1000 $9.04 $11.14 $8.45 Total Amount Total Total (with extra Ordered Amount discount) 8,669 $80,612.91 $78,510.13 7,176 $81,003.66 $78,067.44 9,241 $80,062.14 $77,778.51 Extra Discount 5.00% If more than $25,000.00 For the Products worksheet, and B D E F H J M N O P A 1 2 3 4 Clients 5 6 7 8 9 10 11 12 13 14 Quantities ordered Gadget1 Gadget2 Gadget3 122 1059 1163 2 1252 250 385 3 898 58 347 4 476 1160 840 5 981 861 884 6 617 1176 1290 7 805 334 1233 8 249 847 9 1404 949 776 10 1030 1080 1476 Amount Before Extra Discount Gadget1 Gadget2 Gadget3 $1,244.400 $11,797.26 $9,827.35 $11,318.08 $2,930.00 $3,465.00 $8,539.98 $719.20 $3,123.00 $4,855.20 $12,922.40 $7,492.80 $9,329.31 $9,832.62 $7,885.28 $5,867.67 $13,100.64 $10,900.50 $7,655.55 $3,914.48 $10,418.85 $9,799.36 $2,918.28 $7,555.24 $12,692.16 $10.837.58 $6,921.92 $9,311.20 $12,031.20 $12,472.20 Total Amount $22,869.01 $17,713.08 $12,382.18 $25,270.40 $27,047.21 $29,868.81 $21.988.88 $20,272.88 $30,451.66 $33,814.60 Amount After Discount (if any) Gadget1 Gadget2 Gadget3 $1,244.40 $11.797.26 $9,827.35 $11,318.08 $2,930.00 $3,465.00 $8,539.98 $719.20 $3,123.00 $4,612.44 $12,276.28 $7,118.16 $8,862.84 $9,340.99 $7,491.02 $5,574.29 $12,445.61 $10,355.48 $7,655.55 $3,914.48 $10,418.85 $9,799.36 $2,918.28 $7,555.24 $12,057.55 $10,295.70 $6,575.82 $8,845.64 $11,429.64 $11,848.59 After Discount Total Amount $22,869.01 $17,713.08 $12,382.18 $24,006.88 $25,694.85 $28,375.37 $21,988.88 $20,272.88 $28,929.08 $32,123.87 1084 For the Clients worksheet

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Accounting

Authors: Ray H. Garrison, Eric W. Noreen, Peter C. Brewer

13th Edition

978-0073379616, 73379611, 978-0697789938

Students also viewed these Accounting questions