I've added your part of the code slightly modified as the select command is not needed most of the time but when you recording a macro Excel always add it. Par example the line
Rows("5:5").Select
Selection.Insert Shift:=xlDown
what you wish to do in this case is to insert a new line at row 5 and shift the old row 5 and all following rows down so the suggetion from Excel can be "condensed" to
Rows("5:5").Insert Shift:=xlDown
What still needs to be changed is value of the "sPath". You must change the "E:\Temp\" to the drive and folder where the files you wish to change is found. I've assumed that the files to be changed all have ".xlsx" endings, if they are ".xls" then change the "sFile" part where it says ".xlsx".
Do I simply open a new macro-enabled file and insert the final macro as a new macro and run it?
Yes that is right. A word of warning. Letting a macro loop through a number of files making changes without first testing the macro could be a very bad idea. So I would suggest you make a test folder and copy 3 or 4 of the files you wish to change to that folder. Then run the macro and check if the result is what you wanted.
Option Explicit
Sub ProcessAllFiles()
Dim sPath As String
Dim Wb As Workbook, sFile As String
sPath = "E:\Temp\"
sFile = Dir(sPath & "*.xlsx")
Application.ScreenUpdating = False
Do While sFile <> ""
Set Wb = Workbooks.Open(sPath & sFile)
Rows("5:5").Insert Shift:=xlDown
Range("A5").FormulaR1C1 = "4.5"
Range("A6").Select
Wb.Close SaveChanges:=True
sFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
Well I guess that is all I can say for the moment. Make your test and if you have problems don't hesitate to post back.
Alf
Bookmarks