不匹配错误/代码无效

时间:2017-02-02 22:32:53

标签: excel vba

这是更新后的代码。我现在得到一个不匹配的错误。如果有人可以提供一些帮助,那就太好了。提前谢谢!

Sub Macro2()

Dim rowcount As Long

Dim target As Variant, startcell4 As Range

Set startcell4 = ActiveSheet.Cells(2, 1)

rowcount = Range(Range("E2"), Range("E2").End(xlDown)).Rows.Count

For i = 2 To rowcount + 1

    If Not ActiveSheet.Cells(i, 26) = ActiveSheet.Cells(i + 1, 26) Then

    Set target = Application.Match(ActiveSheet.Cells(i, 26), Worksheets(19).Range("A6:A3000"), 0)


        If Not IsError(target) Then

        ActiveSheet.startcell4.Offset(0, 17).Value = Worksheets(19).Cells(target + 6, 10)

        Set startcell4 = ActiveSheet.Cells(i + 1, 26)

        End If

    End If

Next i

End Sub

1 个答案:

答案 0 :(得分:0)

更改:

  • "设定目标= ..."到"目标= ..."

  • " ActiveSheet.startcell4"到" startcell4"

  • 稍微重构

来到这个

accepts_nested_attributes_for