Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Run time '424' error in VBA when attempting to use a button to calculate a formula

$
0
0

I have the following linear formula that I would like to use a button in excel to calculate: y = 0.0069x + 17.631

My plan was to input a value that I assigned to the cell "PackageWeight", and then when the button is clicked it calculates the above formula and yields "DispatchMinutes", or "y". I used the following code:

Private Sub TrucksDTButton_Click()

    Dim WeightValue As Double
    Dim MinutesValue As Double

    WeightValue = wsDispatchButtonsSheet.Range("PackageWeight").Value
    MinutesValue = wsDispatchButtonsSheet.Range("DispatchMinutes").Value

    MinutesValue = 0.0069 * WeightValue + 17.631

End Sub

However, whenever I run the code, it yields the "Run time '

424' Error - Object Required".

Where did I go wrong in this code?


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>