=IF((1+IF(MID(A1,3,1)=MID(A1,4,1),0,1)+IF(ISERROR(FIND(MID(A1,2,1),MID(A1,3,2))),1,0)+IF(ISERROR(FIND(LEFT(A1,1),MID(A1,2,3))),1,0))=2,IF(OR((ISERROR(FIND(LEFT(A1,1),MID(A1,2,3)))),ISERROR(FIND(RIGHT(A1,1),MID(A1,1,3)))),31,IF(LEN(SUBSTITUTE(A1,LEFT(A1,1),""))=1,31,22)),1+IF(MID(A1,3,1)=MID(A1,4,1),0,1)+IF(ISERROR(FIND(MID(A1,2,1),MID(A1,3,2))),1,0)+IF(ISERROR(FIND(LEFT(A1,1),MID(A1,2,3))),1,0))
in a cell (say A2) and from that cell (in say, A3) use the formuls:
="M"&IF(A2=4,24,IF(A2=3,18,IF(A2=1,1,IF(A2=31,4,6))))
to give the answer required for the first cell (I didn't check this formula)
Bookmarks