View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Help me automate a macro

As Bob pointed out, VBA has its own function to format (which is ironically
called format -you'd think that would be an easy one to remember!).

Format(Date, "yyyymmdd")

If you want to leave it open, you could use OnTime (check VBA help for
details) to run the macro. You could put this in a Workbook_Open event
handler and leave the workbook open (at least until it runs). I've never
needed the Windows Task Scheduler, so I don't have an opinion on which would
be more functional.


" wrote:

application.text(date,"yyyymmdd") is AWESOME! A single line of code
that does exactly what I need.

Now, the last piece of the puzzle is how to run the macro at a given
time each day. Would it be better to set the macro to autorun when
opened and then create a windows scheduled task to open the file every
day, or is there some way to leave the file open and have the macro
automatically kick off at a give time each day?

Tim

JMB wrote:
Or application.text(date,"yyyymmdd") in your code.


" wrote:

I have an Excel report that I have to run every day. It requires one
piece of manually entered data. I have to type in the date in the
format yyyymmdd (ex. 20060713). If I could figure out a way to get
this data into the program automatically, then I could set the macro to
run on a schedule and I wouldn't have to do it every morning.

Any help is appreciated.

TIm