Backup copy in a different location

lapta301

Well-known Member
Joined
Nov 12, 2004
Messages
1,001
Office Version
  1. 365
Platform
  1. Windows
I'm using the following workbook code to frequently save a timed and dated copy of the file in a backup location elsewhere before saving the file at it's normal location.


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim fn As String, ext As String, ipos As Long
ipos = InStr(Me.Name, ".")
fn = Left(Me.Name, ipos - 1)
ext = Right(Me.Name, Len(Me.Name) - ipos)

Application.StatusBar = " "

Me.SaveCopyAs "C:\Users\S\Documents\Backup\Excel" & fn & " " & Format(Now, "yyyy-mm-dd_hh_mm_ss") & "." & ext
Application.StatusBar = False
End Sub


However, in the workbook at E16 on a sheet that has the internal name of Sheet16 (as the sheet name is changed by me each month) I have a formula that inserts the current date and time.

What I would like to achieve somehow is that the cell value is saved not the formula but only on the backup copy.

I should mention that after I save the file I normally carry on working and may save a number of additional copies before I shut up shop for the day so it is not just a case of saving the backup copy after the working copy is saved

I hope that this makes sense

As always any help is much appreciated
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Slightly confused as to whether I've understood what you're asking as it seems to be (far) simpler than you've already done

eg
Code:
Dim mCell as Date
mCell=thisworkbook.sheets("Sheet16").range("E16")

Then use that value in the save copy as portion
 
Upvote 0
Hi Scott


Thank you for showing an interest.

Let me explain.

I can spend hours on this workbook and whenever I saved it I wanted a dated and timed backup copy saved in another location and the code that I have shown does that perfectly.

The only issue that I have had for a long time now is that if I go back to have a look at an older version which may be months, old in that particular cell it shows todays date rather than the date and time that it was saved.

Yes I know that I can identify the date from the file properties but it would be helpful if possible to have the formula in E16 replaced by the actual value instead of the formula.
 
Upvote 0
That makes much more sense to me, thanks. Procedure would be this.

In your before save event, overwrite the date time formula with a static value

(eg sheets("Sheet16").range("E16")=sheets("Sheet16").range("E16").value)

Then in an after save event, restore the dynamic formula.

Hope that helps
 
Upvote 0

Forum statistics

Threads
1,215,257
Messages
6,123,916
Members
449,133
Latest member
rduffieldc

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