sassriverrat
Well-known Member
- Joined
- Oct 4, 2018
- Messages
- 655
Good Evening,
I have an ETA calculator (Time/Distance= Speed) that is giving me an error. Now the error takes me to various other bits of codes like my timestamp macro but it's all based on one part here. The Distance (DTG) below is the cause. If I input data into the "S29" cell, it works perfectly. If I try to rely on it to pull the DTG from D10 when D10 is NOT blank, it will error every time. The purpose of the IF below- take from D10 if S29 is blank and if S29 is not blank, use the value of S29.
Thanks for the help
I have an ETA calculator (Time/Distance= Speed) that is giving me an error. Now the error takes me to various other bits of codes like my timestamp macro but it's all based on one part here. The Distance (DTG) below is the cause. If I input data into the "S29" cell, it works perfectly. If I try to rely on it to pull the DTG from D10 when D10 is NOT blank, it will error every time. The purpose of the IF below- take from D10 if S29 is blank and if S29 is not blank, use the value of S29.
Thanks for the help
Code:
Sub ETA_CALC1()
Dim Path1 As Date
Dim Path2 As Date
Dim Path3 As Double
Dim Path4 As Double
Dim Path5 As Double
Dim path6 As Double
Dim Path7 As Date
Dim Path8 As Date
Dim DTG As Double
Dim resp As Integer
'This says that the Distance to go should be in D10 but if we want to use a different mileage than what today's report had list, _
(D10 is on the list), we can input into S32 to use our own distance
'This piece ensures "ETA Arrival ZD" is ready
Worksheets("Developer").Range("F3").FormulaR1C1 = "=IF(AND((Notes!R[10]C[6]+Notes!R[10]C[7])<(('Voyage Specifics'!R[6]C[-3]+'Voyage Specifics'!R[7]C[-3])),(Notes!R[11]C[6]+Notes!R[11]C[7])>(('Voyage Specifics'!R[6]C[-3]+'Voyage Specifics'!R[7]C[-3]))),""Yes"",""No"")"
If ActiveSheet.Range("S29").Value = "" Then
DTG = ActiveSheet.Range("D10").Value
Else: DTG = ActiveSheet.Range("S29").Value
End If
Path1 = ActiveSheet.Range("R28").Value
Path2 = ActiveSheet.Range("T28").Value
Path3 = DTG
Path5 = Sheets("Developer").Range("G2").Value
path6 = ActiveSheet.Range("C5").Value
Path7 = ActiveSheet.Range("F4").Value
Path8 = ActiveSheet.Range("D4").Value
Path4 = (Path3 / (((Path2 + Path1 + (TimeSerial(Path5, 0, 0))) - (Path7 + Path8 + (TimeSerial(path6, 0, 0)))) * 24))
resp = MsgBox("Based on your desired Arrival Time/Date and your mileage input, your speed required to make your ETA is: " & Round(Path4, 1) & " knots" & vbCrLf & vbCrLf & "Would you like to use this ETA for Today's Report?", vbYesNo)
If resp = vbYes Then
ActiveSheet.Range("W33").Value = Format(Path1, "hh:mm;@")
ActiveSheet.Range("Y33:Z33").Value = Path2
End If
End Sub