Hello,
i have fallowing problem:
create a formula to calculate the latest hour in flexible range (e.g. 14:00-22:30 and 22:00-06:00 the code should give 06:00 or 08:00-12:00 and 09:00-14:00 give 14:00, etc) moreover in rage can be blank cell or other value.
This part is already done, so i put this formula into vba and here is my issue.
the code
.FormulaArray = _
"=TEXT(IF(MAX(IF(MID(R[6]C[-7]:R[6]C[-6],6,1)=""-"",IF(MID(R[6]C[-7]:R[6]C[-6],7,5)*1<MID(R[6]C[-7]:R[6]C[-6],1,5)*1,MID(R[6]C[-7]:R[6]C[-6],7,5)*1,""0""),""0""))=0,MAX(IF(MID(R[6]C[-7]:R[6]C[-6],6,1)=""-"",MID(R[6]C[-7]:R[6]C[-6],7,5)*1,""0"")),MAX(IF(MID(R[6]C[-7]:R[6]C[-6],6,1)=""-"",IF(MID(R[6]C[-7]:R[6]C[-6],7,5)*1<MID(R[6]C[-7]:R[6]C[-6],1,5)*1,MID(R[6]C[-7]:R[6]C[-6],7,5)*1,""0""),""0""))),""HH:MM"")"
unfortunately there is 1004 error
i divide this code to 3 different cells and here is surprise - no 1004 error
FormulaArray = _
"=TEXT(IF(MAX(IF(MID(RC[-7]:RC[-6],6,1)=""-"",IF(MID(RC[-7]:RC[-6],7,5)*1<MID(RC[-7]:RC[-6],1,5)*1,MID(RC[-7]:RC[-6],7,5)*1,""0""),""0""))=0,""T"",""F""),""HH:MM"")"
T - if there is shift through the midnight (22:00-06:00; 21:00-01:00, etc)
.FormulaArray = _
"=TEXT(MAX(IF(MID(RC[-7]:RC[-6],6,1)=""-"",MID(RC[-7]:RC[-6],7,5)*1,""0"")),""HH:MM"")"
F - shift end before midnight
.FormulaArray = _
"=TEXT(MAX(IF(MID(RC[-7]:RC[-6],6,1)=""-"",IF(MID(RC[-7]:RC[-6],7,5)*1<MID(RC[-7]:RC[-6],1,5)*1,MID(RC[-7]:RC[-6],7,5)*1,""0""),""0"")),""HH:MM"")"
the last code give me this error if i put it into formula as a T or as a F
Any idea to solve?
Bookmarks