Type MisMatch

sassriverrat

Well-known Member
Joined
Oct 4, 2018
Messages
655
Good Afternoon,

I keep getting a "error 13" Type mismatch for the piece of coding below and I'm not sure why. These are calculators just doing speed*time=distance and variations of that simple formula.

Ideas?

Code:
Sub ETA_CALC1()Dim name As String
name = Sheets("Notes").Range("N4")
Dim Path1 As Double
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])<((R[2]C[-3]+R[2]C[-2])),(Notes!R[11]C[6]+Notes!R[11]C[7])>((R[2]C[-3]+R[2]C[-2]))),""Yes"",""No"")"






If ActiveSheet.Range("S29").Value = "" Then
    DTG = ActiveSheet.Range("D10").Value
    Else: DTG = ActiveSheet.Range("S29").Value
End If


Path1 = MilitarytoTime(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, name)
If resp = vbYes Then
    ActiveSheet.Range("W33").Value = Format(Path1, "hh:mm;@")
    ActiveSheet.Range("Y33:Z33").Value = Path2
    End If
    ActiveSheet.Range("R29").Select
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Where do you get the error(s)?
 
Upvote 0
I do not see where you indicated the statement where the error occurs.

The code that you provided is missing End If just before End Sub. Anything else missing?
 
Last edited:
Upvote 0
Good catch on the End If- I'll put that in....because it wasn't telling me where and no option to debug....could that be because the vba is locked?
 
Upvote 0
The End If is there, just buried slightly ;)

If any of the cells you are reading values from conatain an error, that would give you a Mismatch error.
 
Last edited:
Upvote 0
The End If is there, just buried slightly

Yes. I was fooled by the indentation and tired eyes. Mea culpa!

it wasn't telling me where

Enter the following statement before the first executable statement in the procedure:

On Error GoTo oops

Enter the following before the End Sub statement:

Exit Sub
oops:
Stop
Resume

When you execute the code, any error should go to the Stop statement.

Then press f8 twice to go back to the statement causing the error.
 
Upvote 0
Ahhh issue came from a locked cell (so a new formula couldn't be set like the code was supposed to do!

Thanks guys!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top