Excel/Macro Follow-up


Thanks for the macro you sent to copy an active workbook. Is there a way to input a date instead of renaming the workbook with the today's date? I'd like to be able to create several weekly schedules for like the next several weeks. So could the macro ask me to name the active workbook, I'd enter the date of the week that I want and then it would create it? The workbook name and cell A2 would still match.


Sub ABC()
Dim s As String, bk As Workbook, sh As Worksheet
s = InputBox("Enter Date")
if len(trim(s)) = "" then exit sub
If IsDate(s) Then
 Set bk = ActiveWorkbook
 Set sh = ActiveSheet
 sh.Range("A2").Value = s
 ' change the path to reflect y path
 bk.SaveAs "C:\Myfolder\" & s & ".xls"
 msgbox "You didn't furnish a valid date."
End If
End Sub

the date format you use in entering your date must be valid when used as a  filename.

The sheet that has/needs a date should be the activesheet when you run the code.  

Untested, but it should get you started.

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.