Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to save a file with the following parameters. "Location 8/12/08" The
"Location" will be a static value but the date needs to be the sunday for the previous week. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greg,
You won't be able to include the slash character as part of your filename, so maybe use the underscore character. Sub test() Dim dtPreviousSunday As Date Dim i As Integer i = Application.WorksheetFunction.Weekday(Date) If i = 1 Then dtPreviousSunday = Date - 7 Else i = i - 1 dtPreviousSunday = Date - (i + 7) End If ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday, "mm_dd_yy") End Sub -- Hope that helps. Vergel Adriano "Greg H." wrote: I need to save a file with the following parameters. "Location 8/12/08" The "Location" will be a static value but the date needs to be the sunday for the previous week. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works perfectly, thanks so much!
"Vergel Adriano" wrote: Greg, You won't be able to include the slash character as part of your filename, so maybe use the underscore character. Sub test() Dim dtPreviousSunday As Date Dim i As Integer i = Application.WorksheetFunction.Weekday(Date) If i = 1 Then dtPreviousSunday = Date - 7 Else i = i - 1 dtPreviousSunday = Date - (i + 7) End If ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday, "mm_dd_yy") End Sub -- Hope that helps. Vergel Adriano "Greg H." wrote: I need to save a file with the following parameters. "Location 8/12/08" The "Location" will be a static value but the date needs to be the sunday for the previous week. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i = Application.WorksheetFunction.Weekday(Date)
If i = 1 Then dtPreviousSunday = Date - 7 Else In Vba, another technique is to switch the week reference to the following day (ie Monday) dtPreviousSunday = Date - Weekday(Date, vbMonday) -- HTH :) Dana DeLouis "Greg H." wrote in message ... Works perfectly, thanks so much! "Vergel Adriano" wrote: Greg, You won't be able to include the slash character as part of your filename, so maybe use the underscore character. Sub test() Dim dtPreviousSunday As Date Dim i As Integer i = Application.WorksheetFunction.Weekday(Date) If i = 1 Then dtPreviousSunday = Date - 7 Else i = i - 1 dtPreviousSunday = Date - (i + 7) End If ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday, "mm_dd_yy") End Sub -- Hope that helps. Vergel Adriano "Greg H." wrote: I need to save a file with the following parameters. "Location 8/12/08" The "Location" will be a static value but the date needs to be the sunday for the previous week. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Save, save as, page setup dimmed out in unprotected excel sheet? | Excel Discussion (Misc queries) | |||
SAVE and SAVE AS options disappeared from the drop down FILE menu | Excel Discussion (Misc queries) | |||
Disable save, save as, but allow save via command button | Excel Programming | |||
How to diasble save and save as menu but allow a save button | Excel Programming | |||
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: | Excel Programming |