遍历多个工作簿并根据代码排列数据

时间:2019-04-01 12:43:20

标签: excel vba

我有以下代码,这些代码将位于(保存)在名为“ TestVerificari”的文件夹中的多个工作簿中的“ Sheet1”中的数据进行排列。下面的代码(附后)可以解决问题,但是我必须为每个工作簿手动运行它。有没有一种方法可以将此代码循环插入并针对该文件夹中保存的所有工作簿运行一次?非常感谢你!

Sub VerificariCE()
'
' Macro1 Macro
'

'
    Rows("1:5").Select

    Selection.Delete Shift:=xlUp

    Columns("A:D").Select

    Selection.Delete Shift:=xlToLeft

    Range("A1:B50000").UnMerge

    Columns(2).Delete

    Selection.UnMerge

    Columns("B:B").Select

    Columns("C:D").Select

    Range("C50000").Activate

    Selection.Delete Shift:=xlToLeft

  '''''''''''''''''''''''''''''''''''
    Range("D1").Select

    Selection.Copy

    Range("G1").Select

    ActiveSheet.Paste

    Range("G2").Select

    ActiveCell.FormulaR1C1 = _
        "=TRIM(MID(SUBSTITUTE(RC[-2], """""""", REPT("" "", 999)), 2999, 999))"

    Range("G2").Select

    Selection.AutoFill Destination:=Range("G2:G50000")

    Range("G2:G50000").Select

    Columns("B:B").EntireColumn.AutoFit

    Columns("A:A").EntireColumn.AutoFit

    Columns("G:G").EntireColumn.AutoFit

    Selection.AutoFilter

    ActiveSheet.Range("$A$1:$M$50000").AutoFilter Field:=1, 

Criteria1:=Array( _

        "AutorizareExport", "CautarePF", "CautarePJ", 

"DescarcaRaportClient", _

        "GenereazaRaportClient", "InapoiLaCautare", "InrolareClientNouPF", _

        "IstoricDocumente", "Meniu_DocumentReport", 

"ModificareDateClientPF", _

        "ModificareDateClientPJ", "ModificarePFInitiativaBancii", 

"PaginaCautare", "="), _

    Operator:=xlFilterValues

    Rows("2:2").Select

    Range(Selection, Selection.End(xlDown)).Select

    Selection.Delete Shift:=xlUp


End Sub

0 个答案:

没有答案