Calculate nuymber of month dinamicaly

webdevptg

Board Regular
Joined
May 2, 2019
Messages
51
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
  2. Web
Hi!

I'm having difficulty finding a formula that gives me the number of months a supervisor was responsible for the project, in a given month there can only be 1 supervisor.

Example: The first supervisor (Anh Bohan) started on October 15, 2020 and ended in February 2021, which will give 4 months, because 2nd supervisor (Eusebia Worde) started functions on February 1, 2021.

The last supervisor will have 3 months because it will start on October 15th 2021 and the project ends in December 2021.

I would like to dynamically calculate the number of months that a certain supervisor is in a role, is this possible?

Thanks!

Attach image example
 

Attachments

  • Capture.JPG
    Capture.JPG
    88.1 KB · Views: 19

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi!

You either have to give an exhaustive list of possible ways you type comments in the column to the right of where the numbers ought to be calculated. Also (with no disrespect), I could make it try to "make up" for typos like fev instead of feb (I thought this was for Portuguese for a second), but there is only so much I (or anyone) can predict as to what was meant.

You can see that the following formula works of the written out "date to date" is uniform with no typos (green cells) but it will give an error if that is not the case (yellow cells).

(Note: This code "doesn't mind" if there is more than one space before (or after) any of the words. But if you type "m ay" instead of "may", it won't be okay.)

Blank - Copy.xlsx
ABCDE
1
24oct 2020 to jan 2021
3#VALUE!fev 2021 to apr 2021
43may 2021 to jul 2021
52aug 2021 to sep 2021
6#VALUE!oct 2021 to finish (dec 2021)
74oct 2020 to jan 2021
83feb 2021 to apr 2021
93may 2021 to jul 2021
102aug 2021 to sep 2021
113oct 2021 to dec 2021
Sheet1 (2)
Cell Formulas
RangeFormula
D2:D11D2=DATEDIF(MONTH(MID(TRIM(MID(E2,1,SEARCH("to",E2,1)-2)),1,3)&"1")&"/1/"&MID(TRIM(MID(E2,1,SEARCH("to",E2,1)-2)),SEARCH("2",TRIM(MID(E2,1,SEARCH("to",E2,1)-2)),1),LEN(TRIM(MID(E2,1,SEARCH("to",E2,1)-2)))),MONTH(MID(TRIM(MID(E2,SEARCH("to",E2,1)+2,LEN(E2))),1,3)&"1")&"/1/"&MID(TRIM(MID(E2,SEARCH("to",E2,1)+2,LEN(E2))),SEARCH("2",TRIM(MID(E2,SEARCH("to",E2,1)+2,LEN(E2))),1),LEN(TRIM(MID(E2,SEARCH("to",E2,1)+2,LEN(E2))))),"M")+1
 
Last edited:
Upvote 0
How about
+Fluff 1.xlsm
ABCD
115/10/2020
229/12/2021
3
4
5abcX15/10/20204
601/11/2020 
701/11/2020 
801/11/2020 
910/12/2020 
1015/12/2020 
11X01/02/20213
1215/10/2020 
1315/10/2020 
1415/10/2020 
1515/10/2020 
1615/10/2020 
17X17/05/20213
1815/10/2020 
1916/10/2020 
20X23/08/20212
21 
22X15/10/20213
Master
Cell Formulas
RangeFormula
D5:D22D5=IF(B5="X",DATEDIF(C5,IFNA(EOMONTH(INDEX(C6:C102,MATCH("X",B6:B102,0)),-1),B$2),"m")+1,"")
 
Upvote 0
How about
+Fluff 1.xlsm
ABCD
115/10/2020
229/12/2021
3
4
5abcX15/10/20204
601/11/2020 
701/11/2020 
801/11/2020 
910/12/2020 
1015/12/2020 
11X01/02/20213
1215/10/2020 
1315/10/2020 
1415/10/2020 
1515/10/2020 
1615/10/2020 
17X17/05/20213
1815/10/2020 
1916/10/2020 
20X23/08/20212
21 
22X15/10/20213
Master
Cell Formulas
RangeFormula
D5:D22D5=IF(B5="X",DATEDIF(C5,IFNA(EOMONTH(INDEX(C6:C102,MATCH("X",B6:B102,0)),-1),B$2),"m")+1,"")
Thats it, thank a lot
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top