12,996,709 members (78,205 online)
Rate this:
See more:
Hi.

This is my first vba task. What i need to do is, calculate end date based on the start date and number of days.

I have the values for start date in column A and duration i.e.; number of days in column B. Calculating business days is my second concern as of now. What I first need to know is, how can i use Worksheet_Change event?

What i thought of doing is, when user enters duration in any cell in column A say A(n), Cell B(n) gets selected in the Worksheet_Change event code. And when Start Date is entered in B2, function to calculate End date is called. Please let me know if its a correct approach or not.

Also what caused trouble for me was, when I press Enter key after entering values in cells, the Worksheet event behaves abruptly.

Posted 21-Mar-13 5:43am
richcb 21-Mar-13 11:46am

Simple and complex do not go toether. If it is simple, it is simple, therefore not complex. If it is complex, it is not simple. What have you tried so far, where is your code?
CHill60 21-Mar-13 12:29pm

This seems a rather heavy-handed way of doing things ... what's wrong with just putting a formula into the worksheet to immediately calculate the end date?

Rate this:

## Solution 1

You don't need any vba code. Remeber Excel stores dates as numeric values. So, all you need to do is to create formula, like this:
`C1 = A1 + B1`, where
`C1` is cell, in which formula is stored,
`A1` is cell with date,
`B1` is cell with number of days

To calculate end date in VBA, use DateAdd()[^] function.

Top Experts
Last 24hrsThis month
 RickZeeland 225 ppolymorphe 180 OriginalGriff 115 Karthik Bangalore 90 Member 12464509 80
 OriginalGriff 4,297 ppolymorphe 2,002 Kornfeld Eliyahu Peter 1,893 RickZeeland 1,761 Richard Deeming 1,493