不幸的是,我的collaegue目前正在度假,我坐在这里与他的VBA代码,我总是触发运行时13错误。任何帮助?错误代码标有**Excel VBA运行时错误类型不匹配13
Function checkForMapping(sheetName As String, checkColumn As Integer, displayColumn As Integer, firstRow As Integer, text As String) As Boolean
Worksheets(sheetName).Activate
Dim lastRow As Long
lastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Dim values As String
Dim currentRow As Long
Dim currentValue As String
For currentRow = firstRow To lastRow Step 1
**If Not Round(Cells(currentRow, checkColumn), 1) = Round(1, 10) Then**
currentValue = Cells(currentRow, displayColumn)
If Not InStr(values, currentValue) > 0 Then
If Len(values) > 0 Then
values = values & ", "
End If
values = values & currentValue
End If
End If
Next
checkForMapping = (Len(values) > 0)
If checkForMapping Then
result = MsgBox(text & " " & values, (vbOKOnly + vbInformation), "Info")
End If
感谢您的帮助!
你从哪里得到错误?告诉我们在发生错误时突出显示哪一行 – Dave
@Dave他在行上放了一个** –
该错误消息通常意味着数据类型不匹配,放置断点或应用程序中断时,通过它,你会看到错误在哪里...... –