Excel function that calculate results from two cells depending on which cell is entered before the other

28 views Asked by At

Is there an excel function that calculate results from two cells depending on which cell is entered before the other?

We have a site in which workers do two operations, let's call them A&B.

For each operation, there is a different policy for payment for overtime.

let's say the output for the two operations will be shown in Cells A&B, and calculation of the payment for overtime will be shown in cell C.

So, if the cell A is entered before cell B, if there is an overtime, the payment policy in cell C will be calculated as per operation B policy, as it is the one causing the overtime. and vice versa.

1

There are 1 answers

0
Chronocidal On

If you are open to using , then you could use the Worksheet_Change event to store the "Date/Time Modified" on a second (hidden) worksheet, like so:

Private Sub Worksheet_Change(ByVal Target As Range)
    Sheet2.Range(Target.Address).Value = Now()
End Sub

This would then let you include your "time sheet" in the formula, like this:

=IF(Sheet2!A1 < Sheet2!B1, "First was " & A1 & ", then " & B1, "First was " & B1 & ", then " & A1)

(Obviously, that is just a rough example, and doesn't take into account things like when only 1 of the cells has had data entered, or clearing dates when you delete data)