一个电子表格中的应用程序匹配不匹配,但另一电子表格中不匹配

问题描述 投票:-1回答:1

所以我在Excel电子表格中有一行VBA,这会给我错误Type Type不匹配

Dim INST As Worksheet
Set INST = Sheets("Instructions")
Dim ST1 As Worksheet
Set ST1 = Sheets("DataU1")
'C12 = 99.8 
' The ST1 range are column of numbers that look like 99.8053741455, 99.8193664551, 100.000717163, etc. These numbers are in numerical order
Dataedge = Application.Match(INST.Range("C12"), ST1.Range("B:B"), 1)

上面的代码给了我一个类型不匹配的错误,虽然有更多的代码,但是这不应该对这行代码产生影响。

当我用不同的数字制作自己的工作表时,它可以工作。

Sub Button1_Click()
Dim INST As Worksheet
Set INST = Sheets("Sheet1")
Dim ST1 As Worksheet
Set ST1 = Sheets("Sheet2")
'C12 = 38.2
'Numbers in the range are 31.5, 32.5, 34.1, 36.9, 37.23, 38.51, 39.1
Dataedge = Application.Match(Val(INST.Range("C12")), ST1.Range("B:B"), 1)
If IsNumeric(Dataedge) = True Then
    MsgBox (Dataedge)
'MsgBox Returns 5 
Else
    MsgBox ("NA")
End If

End Sub
``
The above code gives back 5 as it should. Does anyone know what the problem could be?
excel vba types match mismatch
1个回答
0
投票

找到答案。数据已被删除。

© www.soinside.com 2019 - 2024. All rights reserved.