Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Sub CalcTotal() 'declare variables Dim Quantity As Integer Dim Price As Currency Dim Membership As String Dim extendedprice As Double Dim cashbackpercentage As Double Dim
Sub CalcTotal() 'declare variables Dim Quantity As Integer Dim Price As Currency Dim Membership As String Dim extendedprice As Double Dim cashbackpercentage As Double Dim cashbackamount As Double Dim totalaftercashback As Double Dim minpurchase As Double Dim encouragementthreshold As Double 'assign variables Quantity = Range("B3").Value Price = Range("B4").Value Membership = Range("B7").Value cashbackpercentage = Range("B8").Value minpurchase = Range("B22").Value encouragementthreshold = Range("B24").Value 'calculate extended price extendedprice = Quantity * Price Range("B5").Value = extendedprice 'calculate cashbackpercentage Select Case Membership Case "Gold" cashbackpercentage = Range("B16").Value Case "Platinum" cashbackpercentage = Range("B17").Value Case "Black" cashbackpercentage = Range("B18").Value Case Else cashbackpercentage = 0 End Select 'calculate cashback amount if extended price meets or exceeds min purchase If extendedprice >= minpurchase Then cashbackamount = extendedprice * cashbackpercentage Range("B10").Value = cashbackamount Else Range("B10").Value = 0 End If 'calculate total after cashback totalaftercashback = extendedprice - Range("B10").Value Range("B11").Value = totalaftercashback 'display message box encouraging customer to purchase if cashback amount meets or exceeds encouragement threshold If Range("B10").Value >= encouragementthreshold Then MsgBox ("Make the Purchase!") End If End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The provided VBA code is for a subroutine named CalcTotal that performs calculations related to a purchase cashback and membership benefits based on t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started