check if the contents of a cell is a time?

  • Thread starter Thread starter neowok
  • Start date Start date
N

neowok

i have some columns formatted in hh:mm for start time and finish time
and another column which calculates the number of hours for the first
columns.

the problem is there isnt always a time in there, sometimes it may b
"N/A" so what i need is before it does my formula for calculating th
time, which is =V7-T7+IF(T7>V7,1) i need an IF just before that s
that it only attempts to do this IF the contents of those cells ar
actually a time.

should be very simple but cant quite figure out what to write.
basically i need IF V7 AND T7 are a time, then do the rest of m
formula.

Thank
 
If the choices are time or error

=if(Or(iserror(T7),iserror(V7),T7="",V7=""),"",formula)

or use IsNA instead of iserror.
 
Function If_Time(Cell1, Cell2)

If Range(Cell1.Address).NumberFormat = "h:mm:ss" Then
If Range(Cell2.Address).NumberFormat = "h:mm:ss" Then
If_Time = "DO FUNCTION"
End If
End If

End Function

If it's the cell format you are looking at then the above checks the
format of 2 cells to make sure they are numbers then returns "DO
FUNCTION". Replace this with the function you want to carry out.

Duncan
 
changed toms a bit, it was looking for an error in T6 or V6 but ther
wont be an error, itll either contain a time, or "N/A" or be blank.

so now ive got it a
=IF(OR(T6="N/A",V6="N/A",T6="",V6=""),"",V6-T6+IF(T6>V6,1))

the only problem with this is if someone enters something other tha
N/A or blank, itll fail again. is there a way to check whether ther
is a time in that cell or not? this way it doesnt matter what the
enter, if its not a time then it wont try to calculate it.

cant use karrans because all the cell sare in time format anywa
hh:mm.

thank
 
a time value is a number, so you can use IsNumber(T6). A time value is also
between 0 and 1, so you can check that as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top