Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88087

Application Match Mismatch In one Spreadsheet but not another

$
0
0

So I have a line of VBA in a excel spreadsheet that gives me the error Type mismatch

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)

The above code gives a me a type mismatch error and while there is more code then just this it shouldn't have an effect on this line of code.

When I made my own sheet with different numbers it works.

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?

Viewing all articles
Browse latest Browse all 88087

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>