renaming and closing/opening workbooks

u123935

New Member
Joined
Feb 28, 2005
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
The problem I have is that i want to a) write a renamed copy of a current workbook, then b) close that version and c) continue working on the original workbook. I can manage a) but b) and c) elude me. It seems once I write the renamed workbook, the workbook I was working on now has that name, which seems reasonable. I show the relevant code below:-

Set Masterfile = ThisWorkbook
Fname1 = ActiveWorkbook.Name
If InStr(Fname1, ".") > 0 Then
Fname2 = Left(Fname1, InStr(Fname1, ".") - 1)
End If
relPath = ThisWorkbook.Path & "\" & Fname2 & Format(Date, ("ddmmyyyy")) & _
" " & Format(Time, "hhmm") & ".xlsm"
' Fname = ActiveWorkbook.Name
ThisWorkbook.SaveAs Filename:=relPath

' here is where I want to close the renamed workbook and continue processing the original workbook

Look forward to suggestions.

Thanks

Martyn
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try SaveCopyAs rather than SaveAs …​
 
Upvote 0

Forum statistics

Threads
1,215,528
Messages
6,125,338
Members
449,218
Latest member
Excel Master

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