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.
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Watch MrExcel Video

Forum statistics

Threads
1,123,508
Messages
5,602,072
Members
414,498
Latest member
jordanmiller7890

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