Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ? for Ron de Bruin

Ron thanks for your help with deleting all VBE from a
list of file in a specific folder on computer your code
was awesome!!!

Now I want to kind of do the same thing except I want to
delete files that are older than a specific date. All
files are dated in cell C8. Basically - if date is older
than _ then delete file from folder...Is there a way to
do this?

I would just sort my list by date in the file folder but
when I updated the list earlier I change the modified
date to today and can't sort them by date anymore.

Thanks
Chet
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default ? for Ron de Bruin

Hi Chet

If C8 in the first sheet of each workbook have a real date then
try this to delete files that are older then 10 days

See the vba help for the Isdate function.to check the cell value is really a date


Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
'your code
If mybook.Sheets(1).Range("C8") < Now() - 10 Then
mybook.Close False
MsgBox "use Kill FNames to delete the file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in message ...
Ron thanks for your help with deleting all VBE from a
list of file in a specific folder on computer your code
was awesome!!!

Now I want to kind of do the same thing except I want to
delete files that are older than a specific date. All
files are dated in cell C8. Basically - if date is older
than _ then delete file from folder...Is there a way to
do this?

I would just sort my list by date in the file folder but
when I updated the list earlier I change the modified
date to today and can't sort them by date anymore.

Thanks
Chet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ? for Ron de Bruin

Ron your code below does do everything I want except
actually delete the file from the folder. From what I can
tell Kill Fname is not working. Here is my code I
modified to make this cycle throught.

Sub Remove_Files_Older_Than()
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings\120377\My
Documents\Sent Faxes\"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
If mybook.Sheets("Fax Cover").Range("C8") < Now
() - 180 Then
mybook.Close False
MsgBox "use Kill FNames to delete the
file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop

End Sub

The date in cell C8 is listed as 3/14/2004, so I believe
this is a true date you were looking for.

Any thoughts
Chet


-----Original Message-----
Hi Chet

If C8 in the first sheet of each workbook have a real

date then
try this to delete files that are older then 10 days

See the vba help for the Isdate function.to check the

cell value is really a date


Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
'your code
If mybook.Sheets(1).Range("C8") < Now() - 10 Then
mybook.Close False
MsgBox "use Kill FNames to delete the

file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in

message ...
Ron thanks for your help with deleting all VBE from a
list of file in a specific folder on computer your code
was awesome!!!

Now I want to kind of do the same thing except I want

to
delete files that are older than a specific date. All
files are dated in cell C8. Basically - if date is

older
than _ then delete file from folder...Is there a way to
do this?

I would just sort my list by date in the file folder

but
when I updated the list earlier I change the modified
date to today and can't sort them by date anymore.

Thanks
Chet



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default ? for Ron de Bruin

Hi Chet

Change the Msgbox line to this
Kill FNames

The Msgbox is only for testing


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in message ...
Ron your code below does do everything I want except
actually delete the file from the folder. From what I can
tell Kill Fname is not working. Here is my code I
modified to make this cycle throught.

Sub Remove_Files_Older_Than()
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings\120377\My
Documents\Sent Faxes\"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
If mybook.Sheets("Fax Cover").Range("C8") < Now
() - 180 Then
mybook.Close False
MsgBox "use Kill FNames to delete the
file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop

End Sub

The date in cell C8 is listed as 3/14/2004, so I believe
this is a true date you were looking for.

Any thoughts
Chet


-----Original Message-----
Hi Chet

If C8 in the first sheet of each workbook have a real

date then
try this to delete files that are older then 10 days

See the vba help for the Isdate function.to check the

cell value is really a date


Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
'your code
If mybook.Sheets(1).Range("C8") < Now() - 10 Then
mybook.Close False
MsgBox "use Kill FNames to delete the

file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in

message ...
Ron thanks for your help with deleting all VBE from a
list of file in a specific folder on computer your code
was awesome!!!

Now I want to kind of do the same thing except I want

to
delete files that are older than a specific date. All
files are dated in cell C8. Basically - if date is

older
than _ then delete file from folder...Is there a way to
do this?

I would just sort my list by date in the file folder

but
when I updated the list earlier I change the modified
date to today and can't sort them by date anymore.

Thanks
Chet



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ? for Ron de Bruin

Thanks Ron... It amazing how simple things can be if you
just look at them correctly. I did try to add a line Kill
Fnames to your code, but it gave me an error, so I didn't
try it anymore.

Thanks again
Chet


-----Original Message-----
Hi Chet

Change the Msgbox line to this
Kill FNames

The Msgbox is only for testing


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in

message ...
Ron your code below does do everything I want except
actually delete the file from the folder. From what I

can
tell Kill Fname is not working. Here is my code I
modified to make this cycle throught.

Sub Remove_Files_Older_Than()
Dim mybook As Workbook
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir
MyPath = "C:\Documents and Settings\120377\My
Documents\Sent Faxes\"
ChDrive MyPath
ChDir MyPath
FNames = Dir("*.xls")
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If

Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
If mybook.Sheets("Fax Cover").Range("C8") < Now
() - 180 Then
mybook.Close False
MsgBox "use Kill FNames to delete the
file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop

End Sub

The date in cell C8 is listed as 3/14/2004, so I

believe
this is a true date you were looking for.

Any thoughts
Chet


-----Original Message-----
Hi Chet

If C8 in the first sheet of each workbook have a real

date then
try this to delete files that are older then 10 days

See the vba help for the Isdate function.to check the

cell value is really a date


Do While FNames < ""
Set mybook = Workbooks.Open(FNames)
'your code
If mybook.Sheets(1).Range("C8") < Now() - 10

Then
mybook.Close False
MsgBox "use Kill FNames to delete the

file" & FNames
Else
mybook.Close False
End If
FNames = Dir()
Loop


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Chet" wrote in

message ...
Ron thanks for your help with deleting all VBE from a
list of file in a specific folder on computer your

code
was awesome!!!

Now I want to kind of do the same thing except I want

to
delete files that are older than a specific date. All
files are dated in cell C8. Basically - if date is

older
than _ then delete file from folder...Is there a way

to
do this?

I would just sort my list by date in the file folder

but
when I updated the list earlier I change the modified
date to today and can't sort them by date anymore.

Thanks
Chet


.



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questioin for Ron de Bruin Jenny B. Excel Discussion (Misc queries) 7 June 19th 08 03:57 PM
[email protected] Ron de Bruin Excel Discussion (Misc queries) 1 July 21st 05 01:07 PM
For Ron Bruin Please Steved Excel Worksheet Functions 6 April 6th 05 02:19 AM
For Ron de Bruin Please Steved Excel Worksheet Functions 6 March 16th 05 12:46 AM
for Ron de Bruin Valeria[_2_] Excel Programming 1 January 22nd 04 04:42 PM


All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"