我是新的VBA编码和工作的匹配代码。代码工作得很好,当我运行“数据表”中的代码时(表单中的数据都是我的数据,并且必须找到匹配),但是当我在frontpage上运行代码时(Sheet 1 with userforms )代码是debuggen并且说“运行时错误13”。有人可以告诉问题是什么吗?运行时错误13 - 不匹配
有人可以告诉我为什么我的“If isError”不起作用吗?
在此先感谢!
溴
'Find SKU and Test number
Dim icol As Integer
Sheet13.Range("XFD2") = UserForm2.ComboBox1.Value 'Sættes = ComboBox1.value
Sheet13.Range("XFD3") = UserForm2.ComboBox2.Value 'Sættes = ComboBox2.value
icol = [Sheet13.MATCH(XFD2&XFD3,A:A&Q:Q,0)] 'Match af værdien for vores SKU og test nr
With ThisWorkbook.Worksheets("Data sheet")
'If SKU or Test number not found, then messagebox
If IsError("A:A") Then MsgBox "SKU not found": Exit Sub
If IsError("Q:Q") Then MsgBox "Test number not found": Exit Sub
'Add test result/next step and comment
.Cells(icol, 30).Value = Me.ComboBox3.Value
.Cells(icol, 30 + 1).Value = Me.Comments_To_Result.Value
End With
End If
Set objFSO = Nothing
Set openDialog = Nothing
Range("XFD2").Clear
Range("XFD3").Clear
在哪一行你会得到错误? – Vityata
对不起。它是: icol = [Sheet13.MATCH(XFD2&XFD3,A:A&Q:Q,0)]'相匹配的版本SKU og test nr – broder123
您声明'icol'为'Integer'并返回'[Sheet13 .MATCH(XFD2&XFD3,A:A&Q:Q,0)]'不是一个整数,这就是为什么你会得到['Type mismatch(Error 13)'](https://msdn.microsoft.com/en-us /library/aa264979(v=vs.60).aspx) – Tehscript