Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 114
Default Global Macro Adding rows or colums to many Excel files at the same

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   Report Post  
Posted to microsoft.public.excel.misc
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?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharing read-write Excel 2003 files ttt8262 Excel Discussion (Misc queries) 0 April 1st 06 09:39 PM
Deleting rows in a macro in Excel THEFALLGUY Excel Discussion (Misc queries) 4 December 23rd 05 01:59 PM
excel 4.0 macro removal tool Sachin Shah Excel Discussion (Misc queries) 0 August 25th 05 04:17 AM
Macro to copy range from Excel files in folder nc Excel Discussion (Misc queries) 1 June 15th 05 11:11 AM
macro - adding rows to a column that is summed HGood Excel Discussion (Misc queries) 2 December 1st 04 03:28 PM


All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"