nickirvine
08-10-2009, 10:23 AM
Hello Everyone,
Looking for any help or pointers in a tricky macro im trying to set up. Its a little complicated so please stick with me!
I want to be able to enter a date in to a form in word (something like 01/08/2008) i then want to also enter a weekday (mon-fri) I want a macro to add 52 weeks onto the date added, find the weekday before and calculate the number of days different.
i.e enter 01/08/2008 & friday
The macro does it magic and produces (im making these results up as dont have a calender!)
29/07/2009 (the date 52 weeks on), 3 days different (difference between 52 weeks on and the weekday entered)
Something like that. I need these results as variables in the code which I can then fiddle around with.
Hope that makes sense. Can anyone offer me any pointers or give me some starting point as I'm lost as to how i can achieve this or where to start.
I'm guessing you need to convert the date you enter into a number, the number of that day in the year (i.e 01/01/09 - would be 1, 02/01/09, would be 2 etc. (ive seen this done somewhere im sure!)
Then add on 364 (52 weeks in days) so.. using 01/01/09 as an example would become 365.
then convert this number back to a date, then somehow work backwards and find the day (the weekday entered in the form) before the day numbered 365.
then on getting this number take it away from 365 to find the difference.
Im sure this method is possible. I'm used to using PHP code and thats way I would do it with that but with VB im very much a newbie. Any help will be greatly appreciated.
Thanks for your time in reading my long winded post!
Looking for any help or pointers in a tricky macro im trying to set up. Its a little complicated so please stick with me!
I want to be able to enter a date in to a form in word (something like 01/08/2008) i then want to also enter a weekday (mon-fri) I want a macro to add 52 weeks onto the date added, find the weekday before and calculate the number of days different.
i.e enter 01/08/2008 & friday
The macro does it magic and produces (im making these results up as dont have a calender!)
29/07/2009 (the date 52 weeks on), 3 days different (difference between 52 weeks on and the weekday entered)
Something like that. I need these results as variables in the code which I can then fiddle around with.
Hope that makes sense. Can anyone offer me any pointers or give me some starting point as I'm lost as to how i can achieve this or where to start.
I'm guessing you need to convert the date you enter into a number, the number of that day in the year (i.e 01/01/09 - would be 1, 02/01/09, would be 2 etc. (ive seen this done somewhere im sure!)
Then add on 364 (52 weeks in days) so.. using 01/01/09 as an example would become 365.
then convert this number back to a date, then somehow work backwards and find the day (the weekday entered in the form) before the day numbered 365.
then on getting this number take it away from 365 to find the difference.
Im sure this method is possible. I'm used to using PHP code and thats way I would do it with that but with VB im very much a newbie. Any help will be greatly appreciated.
Thanks for your time in reading my long winded post!