>last modified

Joe C

Well-known Member
Joined
Oct 17, 2002
Messages
841
I'm using the following to list in a spread sheet all the files in select folders. I know want to list the date next to that and am trying to use .lastmodified, but I cannot seem to write it correclty. Can anyone help?

Code:

f1 = CC & f & ""


With Application.FileSearch
.NewSearch
.LookIn = f1
.FileName = "*.*"
.SearchSubFolders = False
.Execute
For i = 1 To .FoundFiles.Count
ActiveCell.Offset(r - 1, 0).Value = .FoundFiles(i)
ActiveCell.Offset(r - 1, 1).Value = .FoundFiles(i).LastModified
'r1 = r1 + r1

r = r + 1
Next i
End With
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi Joe,

I see two possible sources of problems:

1. Since your code offsets -1 row from the ActiveCell, if the active cell is ever in the first row of the worksheet your code will fail because it will try to access row 0.

2. You didn't mention what CC and f refer to in the following formula:

f1 = CC & f & ""

For this to work, CC concatenated with f should yield a folder path name. The [& ""] does nothing since it is concatenates a null string. Check f1 to make sure it is really the path name you want.

Damon
 
Upvote 0
Thanks for responding. This currently works and teh things you stated were not included to save space. What I was trying to do is add a line which will display the last modified date next to the file name.

On 2002-10-22 16:32, Damon Ostrander wrote:
Hi Joe,

I see two possible sources of problems:

1. Since your code offsets -1 row from the ActiveCell, if the active cell is ever in the first row of the worksheet your code will fail because it will try to access row 0.

2. You didn't mention what CC and f refer to in the following formula:

f1 = CC & f & ""

For this to work, CC concatenated with f should yield a folder path name. The [& ""] does nothing since it is concatenates a null string. Check f1 to make sure it is really the path name you want.

Damon
[/quote]
 
Upvote 0
Thanks for responding. This currently works and teh things you stated were not included to save space. What I was trying to do is add a line which will display the last modified date next to the file name.

On 2002-10-22 16:32, Damon Ostrander wrote:
Hi Joe,

I see two possible sources of problems:

1. Since your code offsets -1 row from the ActiveCell, if the active cell is ever in the first row of the worksheet your code will fail because it will try to access row 0.

2. You didn't mention what CC and f refer to in the following formula:

f1 = CC & f & ""

For this to work, CC concatenated with f should yield a folder path name. The [& ""] does nothing since it is concatenates a null string. Check f1 to make sure it is really the path name you want.

Damon
[/quote]
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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