Saving a time stamp with a macro?

R

Ray Morton

I am converting .csv data files from a SCADA system for
historical data. Once the .csv files have been converted,
I have created and run a macro that sorts out all of the
information and averages things out with nice and neat
formatting. I would like to help my work mates out and
speed things up by adding a "save as" function withing the
macro. My question for all of you is, is there a way
possible to save a timestamp of the day so that you don't
have to manually type in the date and change the name
after the macro has already saved it as a .xls file?

Anything suggestions would be greatly appreciated!!!

Ray Morton
Springfield, Oregon
 
B

Bob Phillips

Ray,

Activeworkbook.SaveAs FileName:= "myFile" & Format(NOW,"dd mmm yyy
hh:mm:ss") & ".xls"
 
R

Ray Morton

I tried typing that into visual basic editor to edit the
macro, it gives me run time error '1004' and then it sends
me to debug to code? Am I just not entering it right?

Ray
 
T

Tom

You can't use colons for naming a file.


Ray Morton said:
I tried typing that into visual basic editor to edit the
macro, it gives me run time error '1004' and then it sends
me to debug to code? Am I just not entering it right?

Ray
 
B

Bob Phillips

Ray,

No, what he means is that you can't use the format for time that I gave you
as it includes a colon, which is an illegal filename character.

Try this instead

ActiveWorkbook.SaveAs Filename:="myFile" & Format(Now, "dd mmm yyy
hh-mm-ss") & ".xls

Change myFiles to your filename (I'm sure you already knew that), and watch
the wrap-around, it's all one line.

Sorry for the confusion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top