ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Mass File Column Insert and Name (https://www.excelbanter.com/excel-programming/396701-mass-file-column-insert-name.html)

Kirk P.

Mass File Column Insert and Name
 
I need to create a procedure that will loop through all files in a specified
path, insert a new column in each file called FileName, then write the actual
file name for that file into the column all the way down the list.

How can I accomplish this?

joel

Mass File Column Insert and Name
 

Sub addcolumns()

Const MyPath = "c:\temp"


First = True
Do
If First = True Then
Filename = Dir(MyPath & "\*.xls")
First = False
Else
Filename = Dir()
End If

If Filename < "" Then
Workbooks.Open (MyPath & "\" & Filename)
Range("B1").EntireColumn.Insert

Range("B1:B100").Value = Filename


End If
Workbooks(Filename).Close
Loop While Filename < ""

End Sub

"Kirk P." wrote:

I need to create a procedure that will loop through all files in a specified
path, insert a new column in each file called FileName, then write the actual
file name for that file into the column all the way down the list.

How can I accomplish this?



All times are GMT +1. The time now is 11:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com