S
Snoopy
Hey guys
You have kindly helped me before, and I hope for a little bit more
My macro (below) makes a filename-list of all FILES in one certain
(SUB)FOLDER, but I need to redesign it to make a list of ALL FILES in
FOLDER + ALL FILES in every SUBFOLDER (on every sublevel) in this
Folder-structure.
I think you guys know the trick - will you share it with me?
Best regards
Snoopy
My macro goes like this:
(How can I modify it?)
Sub ListAllFilesInFolderWithDir()
' Delete existing list in sheet FILES/column B to prepare for new
input
On Error Resume Next
Sheets("FILES").Select
Columns("B:B").Select
Selection.ClearContents
' Search FOLDERS named in celle D1, and make a folder list (Listbox
used for pick one of these for the next move)
Dim WorkFile As String
Dim i As Integer
Path = Range("D1").Value
i = 1
WorkFile = Dir(Path & "*.*")
Do While WorkFile <> ""
Cells(i, 2).Value = WorkFile
WorkFile = Dir()
i = i + 1
Loop
' When picked a subfolder in listbox: make a filename-list og files in
this subfolder (named in celle D2)
If Range("D2").Value <> "" Then
Range("D2").Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
' Finally copy/paste the list into the rihgt position
Range("A5").Select
ActiveSheet.Paste
ActiveCell.Cells.Select
Sheets("TEMP").Select
Range("A1:B1").Select
Selection.Copy
Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 1).Resize(tbl.Rows.Count - 1, tbl.Columns.Count -
1).Select
Selection.PasteSpecial Paste:=xlPasteFormulas,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Selection.Font
End With
Range("A:B").Activate
ActiveCell.Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub
You have kindly helped me before, and I hope for a little bit more
My macro (below) makes a filename-list of all FILES in one certain
(SUB)FOLDER, but I need to redesign it to make a list of ALL FILES in
FOLDER + ALL FILES in every SUBFOLDER (on every sublevel) in this
Folder-structure.
I think you guys know the trick - will you share it with me?
Best regards
Snoopy
My macro goes like this:
(How can I modify it?)
Sub ListAllFilesInFolderWithDir()
' Delete existing list in sheet FILES/column B to prepare for new
input
On Error Resume Next
Sheets("FILES").Select
Columns("B:B").Select
Selection.ClearContents
' Search FOLDERS named in celle D1, and make a folder list (Listbox
used for pick one of these for the next move)
Dim WorkFile As String
Dim i As Integer
Path = Range("D1").Value
i = 1
WorkFile = Dir(Path & "*.*")
Do While WorkFile <> ""
Cells(i, 2).Value = WorkFile
WorkFile = Dir()
i = i + 1
Loop
' When picked a subfolder in listbox: make a filename-list og files in
this subfolder (named in celle D2)
If Range("D2").Value <> "" Then
Range("D2").Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
' Finally copy/paste the list into the rihgt position
Range("A5").Select
ActiveSheet.Paste
ActiveCell.Cells.Select
Sheets("TEMP").Select
Range("A1:B1").Select
Selection.Copy
Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 1).Resize(tbl.Rows.Count - 1, tbl.Columns.Count -
1).Select
Selection.PasteSpecial Paste:=xlPasteFormulas,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
With Selection.Font
End With
Range("A:B").Activate
ActiveCell.Cells.EntireColumn.AutoFit
Range("A1").Select
End Sub