Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default saving with a date

Could anyone tell me how you can save a file with a date one day before
today's date but if it falls on a holiday to save it with the prior date.
Thank you.
--
Patricia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default saving with a date

Some pseudo code:

dt = Date - 1
for each cell in Range("Holidays")
if dt = cell then
dt = dt - 1
exit for
end if
Next
Activeworkbook.SaveAs "C:\ABC\BaseName" & format(dt,"yyyymmdd") & ".xls",
xlWorkbookNormal

if you consider a holiday to include weekends, then it would involve more
checking.

--
Regards,
Tom Ogilvy


"Patricia" wrote:

Could anyone tell me how you can save a file with a date one day before
today's date but if it falls on a holiday to save it with the prior date.
Thank you.
--
Patricia

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default saving with a date

Assuming the holidays are stored in a named range

Dim SaveDate As Date

SaveDate = Date - 1
If Weekday(SaveDate) = 1 Then
SaveDate = SaveDate - 2
ElseIf Weekday(SaveDate) = 7 Then
SaveDate = SaveDate - 1
End If
If Not IsError(Application.Match(Range("holidays"), 0)) Then
SaveDate = SaveDate - 1
End If
ActiveWorkbook.SaveAs Filename:=Format(SaveDate, "yyyy-mm-dd")


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Patricia" wrote in message
...
Could anyone tell me how you can save a file with a date one day before
today's date but if it falls on a holiday to save it with the prior date.
Thank you.
--
Patricia



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default saving with a date

so I would have to save a calendar of holidays. I think this will work. Thank
you.
--
Patricia


"Bob Phillips" wrote:

Assuming the holidays are stored in a named range

Dim SaveDate As Date

SaveDate = Date - 1
If Weekday(SaveDate) = 1 Then
SaveDate = SaveDate - 2
ElseIf Weekday(SaveDate) = 7 Then
SaveDate = SaveDate - 1
End If
If Not IsError(Application.Match(Range("holidays"), 0)) Then
SaveDate = SaveDate - 1
End If
ActiveWorkbook.SaveAs Filename:=Format(SaveDate, "yyyy-mm-dd")


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Patricia" wrote in message
...
Could anyone tell me how you can save a file with a date one day before
today's date but if it falls on a holiday to save it with the prior date.
Thank you.
--
Patricia




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default saving with a date

Thank you, Tom.
--
Patricia


"Tom Ogilvy" wrote:

Some pseudo code:

dt = Date - 1
for each cell in Range("Holidays")
if dt = cell then
dt = dt - 1
exit for
end if
Next
Activeworkbook.SaveAs "C:\ABC\BaseName" & format(dt,"yyyymmdd") & ".xls",
xlWorkbookNormal

if you consider a holiday to include weekends, then it would involve more
checking.

--
Regards,
Tom Ogilvy


"Patricia" wrote:

Could anyone tell me how you can save a file with a date one day before
today's date but if it falls on a holiday to save it with the prior date.
Thank you.
--
Patricia

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
saving a file with a date pat67 Excel Worksheet Functions 3 October 8th 09 08:39 PM
Saving to subdirectory using date() pvm3911 Excel Programming 1 August 24th 05 07:27 AM
Date not Saving As Expected Kdub via OfficeKB.com[_2_] Excel Programming 3 June 30th 05 04:00 PM
Saving file as a date Jamie Excel Programming 1 May 19th 05 12:15 PM
Saving with date in filename Ben Allen Excel Programming 3 April 26th 04 09:05 AM


All times are GMT +1. The time now is 11:53 AM.

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

About Us

"It's about Microsoft Excel"