搜索工作表,然后将列复制到另一个工作表

时间:2018-04-26 15:34:55

标签: excel vba excel-vba excel-2010

我正在尝试搜索工作簿中的工作表,查找特定的时间戳,然后将相应的行复制到单独的工作表中。我使用宏录制器来了解从哪里开始,这有助于构建阵列。但是我需要的特定数据不会总是存在于单元格中。例如。

我有点不确定如何在整个文件中搜索此数组,然后将列复制到名为Database

的工作表中

谢谢!

Sub CopyData()

    Sheets("temp7").Range("$A$1:$J$141091").AutoFilter Field:=1, Criteria1:=Array( _
        "02/22/2018 00:00:00", "02/22/2018 01:00:00", "02/22/2018 02:00:00", _
        "02/22/2018 03:00:00", "02/22/2018 04:00:00", "02/22/2018 05:00:00", _
        "02/22/2018 06:00:00", "02/22/2018 07:00:00", "02/22/2018 08:00:00", _
        "02/22/2018 09:00:00", "02/22/2018 10:00:00", "02/22/2018 11:00:00", _
        "02/22/2018 12:00:00", "02/22/2018 13:00:00", "02/22/2018 14:00:00", _
        "02/22/2018 15:00:00", "02/22/2018 16:00:00", "02/22/2018 17:00:00", _
        "02/22/2018 18:00:00", "02/22/2018 19:00:00", "02/22/2018 20:00:00", _
        "02/22/2018 21:00:00", "02/22/2018 22:00:00", "02/22/2018 22:00:00"), Operator:=xlFilterValues
    Range("A27").Select
    ActiveCell.FormulaR1C1 = "02/22/2018 00:00:00"
    Sheets("Database").Select
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "02/22/2018"
    Range("C4").Select
    Sheets("temp7").Select
    Range("F27:F577").Select
    Selection.Copy
    Sheets("Database").Select
    Range("B2").Select
    ActiveSheet.Paste
    Range("A28").Select
End Sub

0 个答案:

没有答案