Getting a formula to apply to all previous response, not just most recent one

Hi everyone,

I am trying to get a message box to display a total cost. My issue is that the formulas are only applying to the most recently entered data. Any idea on how to get them to apply to all of the prior responses?

 

Thanks!

 

If unitsPurchased >= minPurchase Then

           totalCost = unitsPurchased * unitCost * (1 – discountPct)

            MsgBox “You purchased ” & unitsPurchased & ” units of product ” & productCode & “. The total ” _

                & “cost is ” & Format(totalCost, “$###,##0.00”) & “. Because you purchased at least ” _

                & minPurchase & ” units, you got a discount of ” & Format(discountPct, “0.00%”) _

                & ” on each unit.”, vbInformation

        Else

            totalCost = unitsPurchased * unitCost

            MsgBox “You purchased ” & unitsPurchased & ” units of product ” & productCode & “. The total ” _

                & “cost is ” & Format(totalCost, “$###,##0.00”) & “.”, vbInformation

         End If

    Next

        If unitsPurchased >= minPurchase Then Discount = unitsPurchased * unitCost * discountPct

        GrossCost = totalCost + Discount

        grandTotalCost = grandTotalCost + totalCost

 

    MsgBox ” You purchased ” & Format(nProductsPurchased, “###”) & ” products. Without the discount this would have cost you ” & Format(GrossCost, “$###,###.00″) & ” Your total discount was ” & Format(Discount, “$###,###.00”) & “. The total cost of all products you purchased is ” & Format(grandTotalCost, “$#,##0.00”) _

        & “.”, vbInformation, “Grand total”

 

By: Tina

Leave a Reply

Your email address will not be published. Required fields are marked *