LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 354
Default Automate Monthly Task

Rick,

Thanks for your help, it works great and using a module should be fine.
However, I have a couple of questions:

1) I forgot to mention this in my original post - Is there any way to
exclude weekends?

2) I used a command button to call the module because I wont be the only one
generating the reports. Is it possible to hide the command button in the
copied workbooks?

- Daniel

-----------
"Rick Rothstein (MVP - VB)" wrote:

I'm going to sleep for now, but I just wanted to tell you to check back here
over the next few days to see if I, or one of the other volunteers, have
come up with a method that doesn't involve adding a Module into each newly
created workbook file.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Okay, I don't know if this will be totally acceptable to you or not. It
requires you to add a Module (so as not to affect any existing code
procedures or modules) and that Module will be copied into each newly
created file where it will lie dormant and unused. It will affect nothing
to leave this Module in place, but it is something "extra" that will exist
in your new workbooks. Anyway, try this out on a copy of your template to
see if you like it or not.

To start, insert a new Module into your (copy of the) template, copy/paste
the code following my signature into the Module's code window, change the
directory assigned to the Path variable to point to a test directory for
your testing of this code, and then run the code in the Module (that is,
put your cursor in the code of the Module and then click the Run button).
You will be asked for the month you want to create the files for (if you
put a month number in that is less than the current month (like would
happen in December), the year for next year will be used instead of the
current year. Anyway, after you run the code, you will get a new file,
with the name you specified which has the year as indicated above, for
each day of the month (with the date placed in A1 of the first sheet).

One other note... I notice you used forward slashes in your directory
path... I'm guessing that is a network location... I don't have a network
here to test on, so my test was performed to a normal hard drive attached
to my system. NOTE that I add a slash after the directory name you
provided... it is mandatory that any path you provide to the Path variable
end in a slash of the appropriate type (back slash for normal hard drives
and, I am guessing, forward slash for network drives).

Rick

Sub SaveMonthlyDays()
Dim X As Long
Dim Mnth As Long
Dim Dte As Date
Dim Path As String
Path = "//rich5019/Common/West Region/SLC114/SLC CUT TIME REPORT/"
Mnth = InputBox("Enter the month as a number", "Get Month")
With Range("A1")
For X = 1 To Day(DateSerial(Year(Now) - _
(Mnth < Month(Now)), Mnth + 1, 0))
Dte = DateSerial(Year(Now) - (Mnth < Month(Now)), Mnth, X)
.Value = Dte
.NumberFormat = "dd/mm/yyyy"
ThisWorkbook.SaveAs Path & Format(Dte, "dd-mm-yy")
Next
End With
End Sub

 
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
How to automate this task [email protected] Excel Discussion (Misc queries) 2 July 14th 06 12:38 AM
macro for excel, automate task [email protected] Excel Programming 4 May 18th 06 03:40 PM
VB Script to automate Excel does not run as Sheduled Task dan artuso Excel Programming 2 May 12th 06 08:41 PM
can i automate task reminders in excel shootist55 Excel Discussion (Misc queries) 0 May 3rd 05 12:37 AM
Need a simple VBA code to automate a repetitive task. madhu Excel Programming 2 January 21st 05 10:55 AM


All times are GMT +1. The time now is 05:06 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"