Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default save with date

here is the code

Sub dater()

Dim fname

Range("a1").Select
Selection = "=NOW()"

fname = Worksheets("sheet1").Range("A1").Value
fname = fname & ".xls"
ChDir "C:\WINNT\Profiles\u436825\Desktop"
ActiveWorkbook.SaveAs FileName:=fname
End Sub

it is supposed to put the date in cell a1 and then save the file wit
the date as the name. It gets an error on the last line

anyhelp appreciated

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default save with date

Is your date in cell $A$1 formatted as mm/dd/yyyy? You cannot use slashes in
a filename, and will need to write a routine to replace them with something
else (i.e. "-"). See the Help topic "Guidelines for naming workbooks".

--
Regards,
Bill


"ksnapp " wrote in message
...
here is the code

Sub dater()

Dim fname

Range("a1").Select
Selection = "=NOW()"

fname = Worksheets("sheet1").Range("A1").Value
fname = fname & ".xls"
ChDir "C:\WINNT\Profiles\u436825\Desktop"
ActiveWorkbook.SaveAs FileName:=fname
End Sub

it is supposed to put the date in cell a1 and then save the file with
the date as the name. It gets an error on the last line

anyhelp appreciated.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default save with date

Range("a1").Select
Selection = "=NOW()"

try instead
Range("a1").Value = Format$(Now , "yyyymmmdd")
--
Patrick Molloy
Microsoft Excel MVP

"ksnapp " wrote in message
...
here is the code

Sub dater()

Dim fname



fname = Worksheets("sheet1").Range("A1").Value
fname = fname & ".xls"
ChDir "C:\WINNT\Profiles\u436825\Desktop"
ActiveWorkbook.SaveAs FileName:=fname
End Sub

it is supposed to put the date in cell a1 and then save the file with
the date as the name. It gets an error on the last line

anyhelp appreciated.


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default save with date

ksnapp wrote in message ...
here is the code

Sub dater()

Dim fname

Range("a1").Select
Selection = "=NOW()"

fname = Worksheets("sheet1").Range("A1").Value
fname = fname & ".xls"
ChDir "C:\WINNT\Profiles\u436825\Desktop"
ActiveWorkbook.SaveAs FileName:=fname
End Sub

it is supposed to put the date in cell a1 and then save the file with
the date as the name. It gets an error on the last line


The default date string contains invalid characters for a filename.
Change the date format, for example:-

Range("a1").Select
Selection = "=NOW()"
Selection.NumberFormat = "ddmmyyyy hh-mm"
fname = Selection.Text & ".xls"
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
Last Save Date Fordbfilm Excel Discussion (Misc queries) 1 June 24th 09 05:22 PM
Recovering File Info Specifically Save Date or Print Date Gadgetgw Excel Discussion (Misc queries) 4 October 6th 08 08:43 PM
Last Save Date Ben Excel Discussion (Misc queries) 2 June 28th 07 05:00 PM
save as future date eg expected delivery date ryan Excel Discussion (Misc queries) 0 June 21st 07 03:35 PM
add a date that changes only when I save the doc. lauras03 Excel Worksheet Functions 1 February 16th 07 08:47 PM


All times are GMT +1. The time now is 07:02 AM.

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

About Us

"It's about Microsoft Excel"