hi,
I agree the formula is too complex, but works as I have been using it for a while and gives the results I am looking for.
I have got 7 columns:
A contains time stamp
B to F values
Column H should check value in cells B to F. As long as the logical test is true, than blank(“”). If the logical test is false it should subtract time form column A.
B to F logical test
B=0
C=0
D=0
E=0
F<0
I think this is covert by the VBA if
If Cells(i, 2) = 0 Or Cells(i, 3) = 0 Or Cells(i, 4) = 0 Or Cells(i, 5) = 0 Or Cells(i, 6) < 0 Then Cells(i, 8).Value = "" Else Cells(i, 8).Value = Cells(i + 1, 1).Value - Cells(i, 1).Value
On Error Resume Next
All the results are saved in column H.
Depends on quality of data I am receiving the subtract of time gives negative number, in order to avoid it I have created the VBA if, which looks for negative numbers and replace them with blank (“”)
If Cells(i, 8) < 0 Then Cells(i, 8).Value = ""
I think the loop approach is correct, please correct me if I am wrong.
Is it possible to replace the long expression:
If Cells(i, 2) = 0 Or Cells(i, 3) = 0 Or Cells(i, 4) = 0 Or Cells(i, 5) = 0
to something like this:
If Cells(i, j) = 0
If yes, would it help and reduce time?
Flooyd
Bookmarks