Save as backup but stay in current File

DenverWill81

New Member
Joined
Apr 29, 2022
Messages
7
Office Version
  1. 2016
Okay... this seems tricky and I don't have any good examples of code to post but here's what I'm trying to do...

I have this userform:
1652983687726.png


The XXXX part will refer to a project name based on which 'Delete' button was click and I think I can figure that out.
Clicking "Yes" will just plow forward with the project deletion macro.
Clicking will "End" all macros.
And what I'd like to have happen when you click the "Save Backup" button is for a macro to save a back up file with the same name as the current one plus YYMMDD_HH:MM but stay in the current file? So just create a backup to the side without actually switching to the backup. I could also do a Save As with the time stamp and then reopen the original file but I'm not sure if that would work in the middle of a macro.

Is that even possible?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

DenverWill81

New Member
Joined
Apr 29, 2022
Messages
7
Office Version
  1. 2016
Holy Cow! That worked instantly - Bravo sir!
Thanks for the help!
Here's what I ended up going with for people with the same question in the future:

VBA Code:
Private Sub CommandButton2_Click()

    Dim WB As String
    Dim DT As String
    
    WB = Replace(Application.ActiveWorkbook.Name, ".xlsm", "")
    DT = format(CStr(Now), "YYMMDD_HHMM")

    ThisWorkbook.SaveCopyAs WB & " " & DT

    Unload Me
    Call DeleteSingleProject

End Sub
 
Upvote 0
Solution

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,830
Office Version
  1. 365
Platform
  1. Windows
It seems to me that the file extension is needed, no?

VBA Code:
ThisWorkbook.SaveCopyAs WB & " " & DT & ".xlsm"
 
Upvote 0

DenverWill81

New Member
Joined
Apr 29, 2022
Messages
7
Office Version
  1. 2016
It seems to me that the file extension is needed, no?

VBA Code:
ThisWorkbook.SaveCopyAs WB & " " & DT & ".xlsm"
Oh, yes indeed. Good catch!

Now I'm having trouble with the label that I was so confident I could figure out...
Please let me know if I need to post this to a new thread.

Here's what I have so far...
The macro that calls this Userform begins like this:
VBA Code:
Sub DeleteSingleProject()

    ' Identify which Delete button called the macro
    Dim s As Shape
    Set s = ActiveSheet.Shapes(Application.Caller)
    ' Identify the Project Name
    Dim Pname As range
    Set Pname = range(s.TopLeftCell.Address).Offset(, 1)
    ' Identify the Project Number
    Dim Pnum As range
    Set Pnum = range(s.TopLeftCell.Address).Offset(, 16)

DeleteSingleProjectUF.Show

Then over in the UserForm I have this:

Excel Formula:
Private Sub DSPUF_Initialize()

Private Sub DSPUF_Initialize()

Me.Label1.Caption = "Are you sure you want to delete " & Pname & "?" & vbNewLine & vbNewLine & "Click Yes to move forward, Save As to save a new version before deletion, or Cancel."

End Sub

End Sub

I was hoping the Userform would use the variable from the DeleteSingleProject macro to dynamically update the message but all I keep getting is "Label1" like this:
1652989174681.png


Does it have something to do with the label properties or am I way off?
1652989215745.png
 
Upvote 0

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,830
Office Version
  1. 365
Platform
  1. Windows
Yes, please start a new thread for your new question. ;)

Cheers!
 
Upvote 0

Forum statistics

Threads
1,187,148
Messages
5,961,885
Members
438,569
Latest member
Gogleguy

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