steve400243
03-21-2017, 11:09 AM
Hello I use the below code to calculate storage charge's after 7 days. It is not calculating correctly After the first month, it would need to be another $40.00 or 0.04 per pound. after 30 calendar days. C4 is the Pickup Date, and A12 is the delivery date, H10 is the Weight in Pounds. Please help me figure this out, I have played around with the code enough.
Private Sub Worksheet_Calculate()
Dim myDays As Long
Dim myRate As Double
Application.EnableEvents = False
myDays = DateDiff("d", Range("C4").Value, Range("A12").Value)
If myDays >= 7 Then
myRate = Range("H10") * 0.04
If myRate < 40# Then myRate = 40#
End If
Range("J25").Value = myRate
Application.EnableEvents = True
'MsgBox myDays
End Sub
Private Sub Worksheet_Calculate()
Dim myDays As Long
Dim myRate As Double
Application.EnableEvents = False
myDays = DateDiff("d", Range("C4").Value, Range("A12").Value)
If myDays >= 7 Then
myRate = Range("H10") * 0.04
If myRate < 40# Then myRate = 40#
End If
Range("J25").Value = myRate
Application.EnableEvents = True
'MsgBox myDays
End Sub