>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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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
 

Joe C

Well-known Member
Joined
Oct 17, 2002
Messages
841
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]
 

Joe C

Well-known Member
Joined
Oct 17, 2002
Messages
841
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]
 

Forum statistics

Threads
1,143,739
Messages
5,720,578
Members
422,292
Latest member
Bernd0501

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
Top