G
Guest
Hi
In a text cell I want to check if the user have entered a valid interval. A valid intervall looks like this 33:01:00. The checks I want to do is
1) check if the length is 8
2) check if their are only numbers in the positions 1,2,4,5,7 and 8
3) check if position 1 and 2 is between 0 and 99
4) check if position 4 and 5 is between 0 and 59
5) check if position 7 and 8 is between 0 and 59
I have created a function that does this but it is to long to be used by the Data Validation control and I think/hope their is a better way to create the function. Any suggestions would be appreciated?
=IF( AND(LEN(B5)=8, NOT(ISERROR(VALUE(MID(B5,1,2)))), MID(B5,3,1)=":", NOT(ISERROR(VALUE(MID(B5,4,2)))), MID(B5,6,1)=":", NOT(ISERROR(VALUE(MID(B5,7,2))))), AND(VALUE(MID(B5,1,2))>=0,VALUE(MID(B5,1,2))<100, VALUE(MID(B5,4,2))>=0,VALUE(MID(B5,4,2))<60, VALUE(MID(B5,7,2))>=0,VALUE(MID(B5,7,2))<60), FALSE)
Regards
/Niklas
In a text cell I want to check if the user have entered a valid interval. A valid intervall looks like this 33:01:00. The checks I want to do is
1) check if the length is 8
2) check if their are only numbers in the positions 1,2,4,5,7 and 8
3) check if position 1 and 2 is between 0 and 99
4) check if position 4 and 5 is between 0 and 59
5) check if position 7 and 8 is between 0 and 59
I have created a function that does this but it is to long to be used by the Data Validation control and I think/hope their is a better way to create the function. Any suggestions would be appreciated?
=IF( AND(LEN(B5)=8, NOT(ISERROR(VALUE(MID(B5,1,2)))), MID(B5,3,1)=":", NOT(ISERROR(VALUE(MID(B5,4,2)))), MID(B5,6,1)=":", NOT(ISERROR(VALUE(MID(B5,7,2))))), AND(VALUE(MID(B5,1,2))>=0,VALUE(MID(B5,1,2))<100, VALUE(MID(B5,4,2))>=0,VALUE(MID(B5,4,2))<60, VALUE(MID(B5,7,2))>=0,VALUE(MID(B5,7,2))<60), FALSE)
Regards
/Niklas