Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have searched this board over and over and can't find what I need to
do. I have created a macro called Joe. What it does is insert columns, create worksheets, and a pivot table. If I need to post the code, I will, not a problem. I am having a problem finding a code to add to this to get it to run for all xls files in the directory, save, and close. I have looked at many I have found here, and can't adopt anything to get it to work. Is there any basic/generic code that can be used? I was hopeful I could use this one: Sub ProcessFiles() Dim i As Long Dim sFolder As String Dim fldr As Object Dim FSO As Object Dim Folder As Object Dim file As Object Dim Files As Object Dim this As Workbook Dim cnt As Long Set FSO = CreateObject("Scripting.FileSystemObject") Set this = ActiveWorkbook sFolder = "C:\MyTest" If sFolder < "" Then Set Folder = FSO.GetFolder(sFolder) Set Files = Folder.Files cnt = 1 For Each file In Files If file.Type = "Microsoft Excel Worksheet" Then Workbooks.Open Filename:=file.Path With ActiveWorkbook With .Worksheets(1) .Range("A16").EntireRow.Insert .Range("A16").Value = "ABC" 'etc. End With .Save .Close End With cnt = cnt + 1 End If Next file End If ' sFolder < "" End Sub And replace the lines that say Range with my macro, no luck. There are several other macro's that I will need to run throughout the quarter on all files in the directory so if there is some basic macro I can use and just copy and paste my macro in, it would be very nice. Thank You! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro - Open all word files in a directory | Excel Worksheet Functions | |||
Seeking help with MACRO or VBA??? Open all files of type in directory and parse | Excel Programming | |||
Macro to move files from one directory to another | Excel Programming | |||
Macro to enumerate subdirs and files in a directory! | Excel Programming | |||
run macro for all files in the directory | Excel Programming |