简体   繁体   中英

Excel VBA Run-time error Type mismatch 13

Unfortunately my collaegue is currently on vacation and I'm sitting here with his VBA-Code, where I always trigger the run-time 13 Error. Any Help? The Error-Code is marked with **

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

Thanks for any help!

You could maybe add the following line before:

If Not IsError(Cells(currentrow, checkcolumn)) Then

and then remember to stick in another

End If after

如果使用:

If Left(Cells(currentRow, checkColumn).Value2, 1) <> "1" Then

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM