for循环中的Vba运行时错误13类型不匹配

时间:2017-10-31 20:54:24

标签: vba excel-vba type-mismatch excel

我坚持使用这段代码。我总是得到这个错误,但我已经设置了所有变量并且是数字。

你能帮帮我吗?

这里是代码

Sub calc()
    Dim betexcel As Workbook
    Dim prono As Worksheet
    Dim test As Worksheet

    Set betexcel = Workbooks("BET EXCEL.xlsm")
    Set prono = betexcel.Worksheets("PRONO")
    Set test = betexcel.Worksheets("TEST")

    Dim db As String
    db = prono.Range("A1").Value


    Dim alldata As Workbook
    Dim i1 As Worksheet

    Set alldata = Workbooks(db)
    Set i1 = alldata.Worksheets("I1")

    Dim i As Integer
    Dim lastRow As Integer

    lastRow = i1.Range("B2").End(xlDown).Row

    For Each Match In test.Range("A6:" & test.Range("A6").End(xlDown).Address)
        MsgBox ("ciao")

        For i = lastRow To 1 Step -1

            If CDate(i1.Range("B" & i).Value) > CDate(Match.Value) Then

                'i1.Rows(i).Delete

            End If

        Next i

 '            Match.Offset(, 1).Select
 '            Selection.Copy
 '            prono.Range("B8").Select
 '            Selection.PasteSpecial Paste:=xlPasteValues


    Next


End Sub

错误发生在If CDate(i1.Range("B" & i).Value) > CDate(Match.Value) Then

0 个答案:

没有答案
相关问题