Run a Macro simultaneously on different workbooks

harsh603

New Member
Joined
Sep 22, 2017
Messages
1
Hello Everyone,

I have a recorded a short macro and was wondering if anyone can tell me how to run it simultaneously on 10 different excel documents or workbooks? I have Excel 2010. The macro Is as below -

Code:
Sub Macro1()
 '
 ' Macro1 Macro
 '
 ' Keyboard Shortcut: Ctrl+a
 '
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Policy Numbers"
    Range("H1").Select
    ActiveCell.FormulaR1C1 = "Errors"
    Columns("H:H").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.EntireRow.Delete
    Rows("1:1").Select
    Range("D1").Activate
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$L$415").AutoFilter Field:=4, Criteria1:="<>"
    Columns("D:D").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 5
    Columns("H:H").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    Columns("D:D").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 5
    ActiveSheet.Range("$A$1:$L$415").AutoFilter Field:=8, Criteria1:= _
        "<>Number*", Operator:=xlAnd, Criteria2:="<>Product*"
    ActiveWindow.SmallScroll Down:=-12
    Columns("H:H").Select
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    Columns("D:D").Select
    Selection.TextToColumns Destination:=Range("D1"), DataType:=xlDelimited, _
        TextQualifier:=xlSingleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="'", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 1)), _
        TrailingMinusNumbers:=True
    Range("D1").Select
    Selection.Cut
    Range("E1").Select
    ActiveSheet.Paste
    Columns("E:E").Select
    ActiveWindow.ScrollColumn = 4
    Range("E:E,H:H").Select
    Range("H1").Activate
    Selection.Copy
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Paste
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("D11").Select
 End Sub

Thank you,
Harsh
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,012
Messages
6,175,937
Members
452,687
Latest member
A_QA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top