0% found this document useful (0 votes)
32 views2 pages

Script Rekap Data Folder DI Excel

This document contains VBA code to perform the following functions: 1. Allow the user to select a folder using a file dialog box. The selected folder path is stored in a cell. 2. List all files and subfolders in a source folder and its subfolders. File details like name, path, type and dates are written to a spreadsheet. 3. Call the file listing subroutine, passing the folder path stored in the cell and flag to include subfolders. Headers are added and columns autosized.

Uploaded by

pank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Script Rekap Data Folder DI Excel

This document contains VBA code to perform the following functions: 1. Allow the user to select a folder using a file dialog box. The selected folder path is stored in a cell. 2. List all files and subfolders in a source folder and its subfolders. File details like name, path, type and dates are written to a spreadsheet. 3. Call the file listing subroutine, passing the folder path stored in the cell and flag to include subfolders. Headers are added and columns autosized.

Uploaded by

pank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Option Explicit

Sub PILIHFOLDER()
Dim SELECTEDFOLDER As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "SELECT FOLDER"
.ButtonName = "CONFIRM"
If .Show = 1 Then
SELECTEDFOLDER = .SelectedItems(1)
Sheet1.Range("N4").Value = SELECTEDFOLDER & "/"
Else
End If
End With
End Sub

Sub DaftarFileFolder(ByVal SourceFolderName As String, ByVal INCLUDESUBFOLDERS As


Boolean)
Dim LARRAY() As String, A As Long
Dim FSO As Object
Dim FOLDERUTAMA As Object
Dim SUBFOLDER As Object
Dim FILEITEM As Object
Dim BARIS As Long

Set FSO = CreateObject("SCRIPTING.FILESYSTEMOBJECT")


Set FOLDERUTAMA = FSO.GETFOLDER(SourceFolderName)
BARIS = Range("A10000").End(xlUp).Row + 1
For Each FILEITEM In FOLDERUTAMA.Files
Cells(BARIS, 1).Formula = FILEITEM.Name
Cells(BARIS, 2).Formula = FILEITEM.Path
Cells(BARIS, 3).Formula = FILEITEM.Type
Cells(BARIS, 4).Formula = FILEITEM.Size
Cells(BARIS, 5).Formula = FILEITEM.DATECREATED
Cells(BARIS, 6).Formula = FILEITEM.DATELASTMODIFIED
BARIS = BARIS + 1
Next FILEITEM

If INCLUDESUBFOLDERS Then
For Each SUBFOLDERS In FOLDERUTAMA.SUBFOLDERS
DaftarFileFolder SUBFOLDER.Path, True
Next SUBFOLDER
End If
Set FILEITEM = Nothing
Set FOLDERUTAMA = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = True
End Sub

Sub AMBILFILEFOLDER()
Dim FOLDERPATH As String
Application.ScreenUpdating = False
FOLDERPATH = Sheet1.Range("N4").Value
ActiveSheet.Activate
Sheet1.Range("A8:F100000").Select
Selection.ClearContents
Range("A7").Formula = "FILE NAME"
Range("B7").Formula = "PATH"
Range("C7").Formula = "TYPE"
Range("D7").Formula = "FILE SIZE (BYTES)"
Range("E7").Formula = "DATE CRATE"
Range("F7").Formula = "DATE LAST MODIFIED"

Range("A7:F7").Font.Bold = True
DaftarFileFolder FOLDERPATH, True
Columns("A:F").Select
Selection.Columns.AutoFit
Sheet1.Range("A1").Select
End Sub

You might also like