+ Reply to Thread
Results 1 to 3 of 3

Discount Calculation using VBA

Hybrid View

  1. #1
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Discount Calculation using VBA

    I have written the below code to calculate Discount Where Discount Slab 4 & Basic Price are Extracted from A Worksheet (File Attached).

    While Debugging the code, when the Procedure reached "Basic Price" I am getting the following Error - "Object doesn't support this property or method"

    Can someone clarify what is wrong?

    Sub ShowDiscount()
    Dim Qty As Integer
    Dim Discount As Double
    Dim DiscCal As Double
    Dim BasicPrice As Double
    Dim DiscP As Double
        Qty = InputBox("Enter Purchase Quantity")
            If Qty > 25 Then Discount = 0.1 'Discount Slab 1
            If Qty > 50 Then Discount = 0.15 'Discount Slab 2
            If Qty > 75 Then Discount = 0.2 'Discount Slab 3
            If Qty > 100 Then Discount = ThisWorkbook.Sheets("Prices").Range("B15").Value 'Discount Slab 4
        DiscCal = Discount * 100
    BasicPrice = ThisWorkbook.Sheets("Prices").Range("B16").Values
        DiscP = BasicPrice - (BasicPrice * DiscCal)
                MsgBox "Discount of " & DiscCal & "% Calculated on Rs. " & BasicPrice
    End Sub
    Attached Files Attached Files
    Last edited by NeedForExcel; 03-24-2013 at 06:50 AM. Reason: File Attachment Forgotten
    Cheers!
    Deep Dave

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Discount Calculation using VBA

    Change "Values" to "Value" in this Line:
    BasicPrice = ThisWorkbook.Sheets("Prices").Range("B16").Values

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Discount Calculation using VBA

    Ooopsss... Done!!

    Marking the Thread as Solved!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1