0

I'm looking for a formula or a VBA code for the following problem.

I need to get the total operational hours in a day (J). This is de difference from the start-up time (I) and the shutdown time (K) over the whole day.

Most of the entries are 2 a day, but as you can see in the picture this one has 4. Previously I had the formula in J : =IF(K49="";0;IF(EXACT(A49;A48);(K49-I48);(K49-I49))) But with 4 entries this does not work anymore (the A49 and A28 are just numbers if they are the same it means that it is the same day)

So where I'm basically looking for is that it will take the shut downtime and looks for the first value in I and that it is calculating the difference in J.

enter image description here

2
  • 1
    Can you better explain what "with 4 entries this does not work anymore" means?
    – FaneDuru
    Commented Jun 20, 2020 at 11:54
  • Like on the picture, there are 4 entries. At the first entry, the machine is started up and the last entry the machine is shut down. Most of the time we perform 2 tasks with the machine but on this day it were 4, so 4 entries.
    – pjs
    Commented Jun 20, 2020 at 14:10

2 Answers 2

0

Referring to another cell can be done, using OffSet(Row, Col). In case you need the cell just above, you use OffSet(-1,0).

1
  • Thank you for the answer and it needs to do that until it finds a cell with a value. How would I do that?
    – pjs
    Commented Jun 20, 2020 at 12:29
0

I would just use some nested IFs to check first the row above, then the one above that, then the one more above. Something like this (sorry, I cannot embed images): https://i.sstatic.net/XLHVO.png

1
  • Thank you this was where i was looking for :)
    – pjs
    Commented Jun 24, 2020 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.