Populate Listindex with 3 columns: Fles name, Path and Date (last time the file changed)

haseft

Active Member
Joined
Jun 10, 2014
Messages
321
Hi,

I had this thread yesterday.
the code works fine för column 1 and 2 in listbox.
I also want to get the date last time the file changed in 3:d column in listbox.
VBA Code:
Private Sub CommandButton10_Click()
'
Dim MyFolder As String
Dim MyFile As String
Dim j As Integer
With Page6ListBox2
 .ColumnCount = 3
 .ColumnWidths = "50;100;50"

  MyFolder = "R:\Education\School\Region"
  MyFile = Dir(MyFolder & "\*.*")
  Do While MyFile <> ""
    With Page6ListBox2
      .AddItem MyFile
      .List(.ListCount - 1, 1) = MyFolder & "\" & MyFile
      .List(.ListCount - 1, 2) = '????
    End With
    MyFile = Dir
  Loop
End With
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
You can use FileDateTime(MyFolder & "\" & MyFile) to get the last modified date and time.
 
Upvote 0
Solution
You can use FileDateTime(MyFolder & "\" & MyFile) to get the last modified date and time.
get error nr "53", can not fine the file
VBA Code:
.List(.ListCount - 1, 2) = FileDateTime(MyFolder & "\" & MyFile)
 
Upvote 0
What is the value of MyFile when the error happens?
 
Upvote 0
I can't reproduce your error. The code works fine here.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top