Saving a file under specific conditions

ribbs2521

Board Regular
Joined
Sep 8, 2007
Messages
158
I was wondering if anyone had any ideas on how to help with this. I have a file that is saved multiple times during an 8 hour shift, what I want to do is

have it look in the destination folder for the file and save it under these conditions:
1. If the file was saved within 12 hours than overwrite it
2. If the file was not saved within 12 hours from now than append an index to the end of the file name.

My code:
Code:
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 8/29/2007 by BerlGeof
'
' Keyboard Shortcut: Ctrl+s
'
Dim MyRange As String
MyName = InputBox("Enter Last name First initial") & " " & Format(Now(), "mm-dd-yy") & ".xls"
MyPath = "V:\Service WW\Global Service\Rochester\Status Reports"
ActiveWorkbook.SaveAs Filename:=MyPath & "\" & MyName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False
End Sub

Right now it just asks for the users last name and first initial and saves it appending the Now() date to the end of the filename. (Inputbox will be changed to grab the users env name so all they do is hit the hotkey for the macro and it saves for them.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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