Run-time error '13' (Type mismatch) is returned The code reads:-
TavgRow = Application.Match(ThisStation, ThisSheet.Range("A1:A115083"), 0)
where
Dim TavgRow As Single
Dim ThisStation As String
The range "A1:A115083" is formated as 'Text'.
If I change the code to read:-
TavgRow = Application.Match("ITE00100554", ThisSheet.Range("A1:A115083"), 0)
it returns without error.
I have tried setting the range to 'General' and the variable 'ThisStation' to 'Variant' but the error persists.
Any suggestions would be appreciated.
To give a more full picture of the code:-
Do While Not EOF(1)
Input #1, ThisStation
Input #1, TheDate
If (ThisStation <> OldStationID Or TheDate <> TheOldDate) And TAVG <> -9999 Then
'Put the data into the spreadsheet and set bits to Zero
TavgRow = Application.Match(ThisStation, ThisSheet.Range("A1:A115083"), 0)
TavgColumn = Application.Match(YearMonth, ThisSheet.Range("A1:NE1"), 0)
If TAVG <> 0 Then TAVG = TAVG / 10
ThisSheet.Cells(TavgRow, TavgColumn) = TAVG
TMAX = -9999
TMIN = -9999
TAVG = -9999
End If
OldStationID = ThisStation
TheOldDate = TheDate
TheYear = Left(TheDate, 4)
TheMonth = Mid(TheDate, 5, 2)
TheDay = Right(TheDate, 2)
YearMonth = TheDay & "," & TheMonth
It all works perfectly except for this one line of code!!!
ThisStation
? – JMPThisStation
, right? – Stavros JonThisStation
, with adebug.print
for example, to see what value it has when the code crashes? – Stavros Jon