Hello everyone,

I’m trying to find out the length of various projects using Excel or VBA. Looking at the image below, the project duration date can be found two different ways. The first way it can be found is the done date – create date. For project 1234, it would be cell B6 – B4. The second way it can be done is completion date/time – create. For project 2211, it would be cell D12 – B13. I want to find a way to do this instead of having to manually type in the formula each time. The only thought I currently have is using a nested if statement or a loop that finds the project duration if there’s a date and time in a cell. In this nested if or loop I am thinking about, it would search for the word create in A4 then look to see if there’s a data/time like in B4. If there is date/time in those cells, it should find the difference and put it in E3. After the word done in any project like in A6, it goes to the next project and searches for the word create again then the process starts over. If there isn’t a done date or a completion date/time like for project 4567, I’d like the loop to skip it if possible. When there isn’t a done date like project 2211 but a completion date/time, I’d like for the if statement or loop to find the difference and place it in E12. Does anyone have an idea of how this can be done?
Screenshot (262).jpg