nicolehalliday
Board Regular
- Joined
- May 19, 2010
- Messages
- 56
Hello,
I am having trouble with dates in my macro. The macro will add one month to a date and return the future date in another cell. The problem is that I want the date to be the exact same (eg. May 14 and then June 14), rather than adding 30 days. All the methods I've tried have just added 30 days so the day is not the same number. I also realize I need to account for certain dates, such as there is Jan 30th but no Feb 30 - in this case I would want to take Feb 28. Here is the code that I've tried so far:
and
I'd also like to give a big thanks to everyone who spends time on Mr. Excel replying to posts. You've helped me so much and I've learned a lot, thank you!
I am having trouble with dates in my macro. The macro will add one month to a date and return the future date in another cell. The problem is that I want the date to be the exact same (eg. May 14 and then June 14), rather than adding 30 days. All the methods I've tried have just added 30 days so the day is not the same number. I also realize I need to account for certain dates, such as there is Jan 30th but no Feb 30 - in this case I would want to take Feb 28. Here is the code that I've tried so far:
Code:
divarray(y, 1) = DateAdd("m", 1, lastdate)
divarray(y, 7) = DateAdd("m", 1, lastpaydate)
divarray(y, 8) = DateAdd("m", 1, recdate)
and
Code:
divarray(y, 1) = "=date(year(" & divarray(x, 1) & "),month(" & divarray(x, 1) & ")+1,day(" & divarray(x, 1) & ")"
divarray(y, 7) = "=date(year(" & divarray(x, 7) & "),month(" & divarray(x, 7) & ")+1,day(" & divarray(x, 7) & ")"
divarray(y, 8) = "=date(year(" & divarray(x, 8) & "),month(" & divarray(x, 8) & ")+1,day(" & divarray(x, 8) & ")"
I'd also like to give a big thanks to everyone who spends time on Mr. Excel replying to posts. You've helped me so much and I've learned a lot, thank you!