Universal Macro

  • Thread starter Thread starter Sam Thurston
  • Start date Start date
S

Sam Thurston

Hello

I have created quite a simple macro in Excel that formats
a spreadsheet the way that i want it to e.g.
deleting/inserting columns/rows, shading, placing borders
etc and i also have the code for this macro.

I was wondering if there is any way to apply this macro to
numerous spreadsheets without having to open each one
seperately and insert the code, so in effect possibly
clicking a button and say 12 spreadsheets run the same
macro simultaneously.

Your help would be greatly appreciated

Thanks

Sam
 
Sam
You can put this macro in your Personal.xls or in any file (spreadsheet)
that's open. Then put all the files that you want to operate on in one
folder. Then modify the macro for the path to that folder. HTH Otto
Sub AllFolderFiles()

Dim wb As Workbook

Dim TheFile As String

Dim MyPath As String

MyPath = "C:\Temp"

ChDir MyPath

TheFile = Dir("*.xls")

Do While TheFile <> ""

Set wb = Workbooks.Open(MyPath & "\" & TheFile)

MsgBox wb.FullName

wb.Close

TheFile = Dir

Loop

End Sub
 
Sam

Open the book with the macro, then open a new workbook.
Press Alt + F8, select the macro and run.

Regards
peter
 
Back
Top