Hi,
I finally got a function together that I THINK will work, but I'm not sure how to test it. The idea is that I need my macro to set cell A1 to hold the first day of next Monday's month. If today is Monday, then it should use today, NOT next monday.
a few examples:
Running the macro today gives 8/1/2002
Running it on 8/25/2002 gives 8/1/2002
Running it on 8/26/2002 gives 8/1/2002
Running it on 8/27/2002 gives 9/1/2002
Running it on 9/01/2002 gives 9/1/2002
I don't know how to test my code for running on any day other than today because it makes use of the "Today()" function and I can't get it to work using a variable instead.
Here's my code:
Dim dayOfWeek
Dim nextMonday
Dim aMonday
Dim numDays
numDays = 7
aMonday = 2
dayOfWeek = Weekday(Now)
nextMonday = (numDays + aMonday - dayOfWeek) Mod numDays
Range("A1").Formula = "=DATE(YEAR(Today()+" & nextMonday & "),MONTH(Today()+" & nextMonday & "),1)"
I'd appreciate any comments on whether it will work and how to test it!
Thanks in advance
Christine
I finally got a function together that I THINK will work, but I'm not sure how to test it. The idea is that I need my macro to set cell A1 to hold the first day of next Monday's month. If today is Monday, then it should use today, NOT next monday.
a few examples:
Running the macro today gives 8/1/2002
Running it on 8/25/2002 gives 8/1/2002
Running it on 8/26/2002 gives 8/1/2002
Running it on 8/27/2002 gives 9/1/2002
Running it on 9/01/2002 gives 9/1/2002
I don't know how to test my code for running on any day other than today because it makes use of the "Today()" function and I can't get it to work using a variable instead.
Here's my code:
Dim dayOfWeek
Dim nextMonday
Dim aMonday
Dim numDays
numDays = 7
aMonday = 2
dayOfWeek = Weekday(Now)
nextMonday = (numDays + aMonday - dayOfWeek) Mod numDays
Range("A1").Formula = "=DATE(YEAR(Today()+" & nextMonday & "),MONTH(Today()+" & nextMonday & "),1)"
I'd appreciate any comments on whether it will work and how to test it!
Thanks in advance
Christine