Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub ListFilesInFolder(SourceFolder As Scripting.folder, IncludeSubfolders As Boolean)
- Dim fName As String
- Dim Lastrow As Long
- On Error Resume Next
- For Each FileItem In SourceFolder.Files
- ' display file properties
- Cells(iRow, 3).Formula = FileItem.Name
- Cells(iRow, 4).Formula = FileItem.Path
- iRow = iRow + 1 ' next row number
- Next FileItem
- Range("C17").CurrentRegion.Select
- Selection.Sort Key1:=Range("C17"), Order1:=xlAscending, Header:=xlGuess, _
- OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
- DataOption1:=xlSortNormal
- With ActiveSheet
- Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
- Lastrow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
- End With
- If IncludeSubfolders Then
- For Each SubFolder In SourceFolder.SubFolders
- ListFilesInFolder SubFolder, True
- Next SubFolder
- End If
- Set FileItem = Nothing
- Set SourceFolder = Nothing
- Set FSO = Nothing
- For iRow = 17 To Lastrow
- Cells(iRow, 2).Formula = iRow - 16
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(iRow, 2), Address:="", _
- TextToDisplay:=CStr(iRow - 16)
- Next
- End Sub
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(iRow, 2), Address:="", _
- TextToDisplay:=CStr(iRow - 16)
- Activesheet.Hyperlinks.Add Anchor:=Cells(iRow, 2), Address:="", _
- ScreenTip:=CStr(iRow - 16)
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(1, 1), Address:="", ScreenTip:=CStr(Cells(1, 1).Value)
- ActiveSheet.Hyperlinks.Add Anchor:=Cells(1, 1), Address:="", TextToDisplay:=Cstr("texthaschanged")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement