muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,077
- Office Version
- 365
- 2021
- Platform
- Windows
hi all..
i have code that working properly only in one sheet (left sheet).
if i run the code in the other sheet (adjacent sheet) the macro not fully working
this code function can to get file name and date modified from a folder
in left sheet or first sheet "file name & date modified from a folder" can be extracted but in adjacent sheet only "file name" can be extracted
how to fit it? the code can running well in different sheet.
here this code :
i hope someone would help out this problem..
any help, greatly appreciated.
.sst
i have code that working properly only in one sheet (left sheet).
if i run the code in the other sheet (adjacent sheet) the macro not fully working
this code function can to get file name and date modified from a folder
in left sheet or first sheet "file name & date modified from a folder" can be extracted but in adjacent sheet only "file name" can be extracted
how to fit it? the code can running well in different sheet.
here this code :
VBA Code:
Sub GetFileNames()
Dim xRow As Long
Dim xDirect$, xFname$, InitialFoldr$
Dim cell As Range, fso As Object
InitialFoldr$ = "x:\t\" '<<< Startup folder to begin searching from
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder to list Files from"
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count <> 0 Then
xDirect$ = .SelectedItems(1) & "\"
xFname$ = Dir(xDirect$, 1)
Do While xFname$ <> ""
ActiveCell.Offset(xRow) = xFname$
xRow = xRow + 1
xFname$ = Dir
Loop
End If
End With
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
For Each cell In Range(ActiveCell, ActiveCell.Offset(xRow))
cell.Offset(0, 1).Value = fso.getfile(xDirect$ & cell.Value2).DateLastModified
Next cell
Set fso = Nothing
On Error GoTo 0
End Sub
any help, greatly appreciated.
.sst