View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Global Macro Adding rows or colums to many Excel files at the same

Try something like the following. It will process all the XLS files in
C:\Test.

Sub AAA()
Dim WS As Worksheet
Dim WB As Workbook
Dim FName As String
Dim SavePath As String
Dim NumRows As Long
Dim InsertAtRow As Long

SavePath = CurDir
ChDrive "C:\Test" '<<< CHANGE PATH
ChDir "C:\Test" '<<< CHANGE PATH
NumRows = 3
InsertAtRow = 2 '<<<< CHANGE TO WHERE NEW ROWS ARE INSERTED

FName = Dir("*.xls")
Do Until FName = vbNullString
Set WB = Workbooks.Open(FName)
Set WS = WB.Worksheets("Sheet1") '<<< CHANGE SHEET NAME
WS.Rows(InsertAtRow).Resize(NumRows).Insert Shift:=xlDown
WB.Close savechanges:=True
FName = Dir()
Loop

ChDrive SavePath
ChDir SavePath
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Bryan" wrote in message
...
If I wanted to create a global macro to insert 3 rows to 60 excel files
that
are all in exactly the same format how would I do that?