Excel VBA:有什么简单的导致错误1004?

时间:2017-08-09 20:47:48

标签: excel-vba vba excel

  Sub copyFilteredData2()

    Dim employee As String
    Dim AutoFiltrng As Range
    Dim rng As Range
    Dim FilterSh As Worksheet
    Dim DashSh As Worksheet
    Dim FilterRng As Range
    Set FilterSh = ActiveWorkbook.Sheets("Report")
    Set DashSh = ActiveWorkbook.Sheets("Metrics Page")
Set FilterRng = FilterSh.Range("A1")
Dim Cell As Range


            FilterRng.AutoFilter field:=19, Criteria1:=DashSh.Range("E4").value

                    With FilterSh.AutoFilter.Range
                    On Error Resume Next

            Set AutoFiltrng = .Offset(1, 0).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible)
                    On Error GoTo 0
            End With

            If AutoFiltrng Is Nothing Then
            MsgBox "No data for that Engineer!"

            Else

            Worksheets(DashSh.Range("E4").value).Cells.Clear

            Set rng = FilterSh.AutoFilter.Range
            rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Copy Destination:=DashSh.Range("E4").value

            End If

            End Sub

我对此代码的目标是使用带有数据验证的数据集来根据值过滤信息,然后复制信息并将其粘贴到名为相同值的电子表格中。最终,我计划构建代码以循环到E4范围:E25。

0 个答案:

没有答案