Thread: Universal Macro
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach[_6_] Otto Moehrbach[_6_] is offline
external usenet poster
 
Posts: 201
Default Universal Macro

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 Thurston" wrote in message
...
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