Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sharing read-write Excel 2003 files | Excel Discussion (Misc queries) | |||
Deleting rows in a macro in Excel | Excel Discussion (Misc queries) | |||
excel 4.0 macro removal tool | Excel Discussion (Misc queries) | |||
Macro to copy range from Excel files in folder | Excel Discussion (Misc queries) | |||
macro - adding rows to a column that is summed | Excel Discussion (Misc queries) |