Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Filename as Date


I have the following Macro, which saves the file to the entry in Cell
AG13.

The Cell AG13 is formatted as a date and I would like to use the macro
but cannot format the filename as a date, when I try it saves as
“False.xls”

Range("ag13").Select

savename = ActiveCell.Value & ".xls "

ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False



Any help would be appreciated.


--
Donkin
------------------------------------------------------------------------
Donkin's Profile: http://www.excelforum.com/member.php...o&userid=23715
View this thread: http://www.excelforum.com/showthread...hreadid=376258

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Macro Filename as Date

savename = Format(ActiveCell.Value,"yyyymmdd") & ".xls "


--
HTH

Bob Phillips

"Donkin" wrote in
message ...

I have the following Macro, which saves the file to the entry in Cell
AG13.

The Cell AG13 is formatted as a date and I would like to use the macro
but cannot format the filename as a date, when I try it saves as
“False.xls”

Range("ag13").Select

savename = ActiveCell.Value & ".xls "

ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False



Any help would be appreciated.


--
Donkin
------------------------------------------------------------------------
Donkin's Profile:

http://www.excelforum.com/member.php...o&userid=23715
View this thread: http://www.excelforum.com/showthread...hreadid=376258



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Filename as Date


How is the date formatted in the cell?

If it has any /'s in it then it may not be valid as a filename.

You could try something like this.

Code
-------------------

savename = Format(Range("ag13").Value, "ddmmyyyy")

-------------------

--
Nori
-----------------------------------------------------------------------
Norie's Profile: http://www.excelforum.com/member.php...fo&userid=1936
View this thread: http://www.excelforum.com/showthread.php?threadid=37625

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro Filename as Date


You can't have "/" in your filename and since these are likely to be i
your date you can't have them.


If your date is in cell B4, you could try this:



FileName = Range("B4").value

FileName = replace(Filename,"/","")

activeworkbook.saveas filename & ".xls

--
FastOneBa
-----------------------------------------------------------------------
FastOneBaz's Profile: http://www.excelforum.com/member.php...nfo&userid=973
View this thread: http://www.excelforum.com/showthread.php?threadid=37625

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Appending filename with date kapil.dalal Excel Programming 5 May 30th 05 11:34 AM
date in filename JCanyoneer Excel Programming 1 April 5th 05 12:08 AM
Saving with date in filename Ben Allen Excel Programming 3 April 26th 04 09:05 AM
Inserting Date In Filename Using Macro Mega_-__ Excel Programming 2 November 27th 03 08:51 PM


All times are GMT +1. The time now is 12:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"