How to get a macro to run on all files in a folder and save each one?

Joined
May 14, 2012
Messages
1
Reaction score
0
I have a macro that I would like to run on every file in a folder that is dumped from our database, to clean it up.

This is the macro:

Sub Macroconnor()
'
' Macroconnor Macro
' formatting
'
' Keyboard Shortcut: Ctrl+d
'
Cells.Select
Range("B4").Activate
Selection.NumberFormat = "#,##0_);[Red](#,##0)"
With Selection
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("A:A").Select
Selection.ColumnWidth = 10
Columns("C:K").Select
Selection.ColumnWidth = 11
Columns("G:G").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.ColumnWidth = 20
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("A1:L1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A2:L2").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A3:L3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A4:L4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
End Sub


I looked around but can't figure out how to make it run on all the files in a single folder. I would appreciate any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top