此应用程序匹配返回类型不匹配错误. 返回



运行时错误"13"(类型不匹配( 代码如下:-

TavgRow = Application.Match(ThisStation, ThisSheet.Range("A1:A115083"), 0)

哪里

Dim TavgRow As Single
Dim ThisStation As String

范围"A1:A115083"的格式为"文本"。

如果我将代码更改为阅读:-

TavgRow = Application.Match("ITE00100554", ThisSheet.Range("A1:A115083"), 0)

它返回时没有错误。

我尝试将范围设置为"常规",将变量"ThisStation"设置为"变体",但错误仍然存在。

任何建议将不胜感激。

为了更全面地了解代码:-

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

除了这一行代码之外,一切都运行良好!!

您需要强制将ThisStation读取为字符串。

用:

TavgRow = Application.Match((ThisStation), ThisSheet.Range("A1:A115083"), 0)

(用括号括ThisStation(代替。

裁判:

  • https://learn.microsoft.com/en-gb/office/vba/Language/Reference/User-Interface-Help/byref-argument-type-mismatch

最新更新