Hello,
I'm still struggeling to figure out the match function and how it works. Sometimes it works just fine and does what I want, other times it just spits out errors without me understanding why.
I'm puzzeled as of why this results in an error:
(Run-time error '13': Type mismatch)
Does anyone have any ideas?
Thank you for your time.
Best regards,
Kasper C
I'm still struggeling to figure out the match function and how it works. Sometimes it works just fine and does what I want, other times it just spits out errors without me understanding why.
I'm puzzeled as of why this results in an error:
(Run-time error '13': Type mismatch)
VBA Code:
Sub test()
Dim ws As Worksheet
Dim wso As Worksheet
Dim wb As Workbook
Dim r As Range
Dim a
Dim i As Long, LRow As Long, LRowo As Long
Dim Vrnr As String
Set wb = Excel.Workbooks("myworkbook.xlsm")
Set ws = wb.Worksheets("Sheet1")
Set wso = wb.Worksheets("Sheet2")
LRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
LRowo = wso.Cells(Rows.Count, 1).End(xlUp).Row
a = ws.Range(ws.Cells(1, 1), ws.Cells(LRow, 1)).Resize(, 7)
Vrnr = ws.Cells(2, 1).Value 'The value of this Cell is "81085", I've also tried without the ".Value"
Set r = wso.Range(wso.Cells(2, 1), wso.Cells(20, 1)) 'This range contains the value "81085", twice. Both in number formats
Bestnr = Application.Match(Vrnr, r, 0) 'This is where the error occurs.
End Sub
Does anyone have any ideas?
Thank you for your time.
Best regards,
Kasper C