About MrExcel
Consulting Services
Learn Excel Resources
Challenge of the Month
MrExcel Seminars

Message Board

MrExcel Store


Deepak asks “Hi ,
I am trying to assign the current date to a cell A38 using =NOW() and then do a SaveAs by assigning the contents
of that cell as the file name for the file being saved. I am not being able to write the correct code for it .

ChDir "C:\Backup"
ActiveWorkbook.SaveAs Filename: = Range("A38").Text, FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

In the above mentioned code all I need to do is to replace the filename by the contents of a cell A38 which will always contain the
current date. I would appreciate if you would please let me know the correct way to write this code. I tried to replace Filename with a few
things looking at tip025 in in but it did not work.”

The problem arises when the format of the date includes the “/” character… try the following:

ActiveWorkbook.SaveAs Application.Substitute(Range(“A38”).Text,”/”,”-“)

By Juan Pablo Gonzalez on 18-May-2002 Consulting can be hired to implement this concept, or many other cool applications, with your data. provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.


Excel is a registered trademark of the Microsoft® Corporation.

All contents Copyright 1998-2008 by MrExcel Consulting.