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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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
It seems to me that the file extension is needed, no?

VBA Code:
ThisWorkbook.SaveCopyAs WB & " " & DT & ".xlsm"
 
Upvote 0
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
Yes, please start a new thread for your new question. ;)

Cheers!
 
Upvote 0

Forum statistics

Threads
1,214,668
Messages
6,120,825
Members
448,990
Latest member
rohitsomani

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