Forum Discussion
How to change the columns a formula will get its data from
So you have a couple options. IF there is only 1 time between the 2 columns (i.e. time will be in EITHER column B OR column C and never BOTH) then you can simple add those 2 columns and subtract column A:
=C3:C6+B3:B6-A3:A6
Note the above is an array formula for the entire columns, if you aren't familiar with that you only need to paste this in the first cell (D3) and it will 'SPILL' down the results to all the corresponding cells
On the other hand IF there could be time in both then you need to determine the order of precedence in the sense of which to use in that case. Let's assume you prefer 'End date/time' (i.e. column C) in that case then you want to use column B if column C is "" otherwise use column C:
=IF(C3:C6="",B3:B6,C3:C6)-A3:A6
So if the value in column C is blank the IF will return column B, otherwise that IF will return column C and then it will subtract column A from whichever value is returned.
NOTE if both columns are blank but there is a date/value in column A both of the above will resullt in an ERROR on that line due to a 'negative' date/time. You can fix that using custom format:
so in columns D & E are the 2 versions I gave above and then I applied a custom number/time format to show hours:min:sec but added a semicolon after that format to say if negative show nothing. BTW the brackets around the hours indicate it can/should show the total hours and go over 24 hours and NOT show only the hour portion of the Days, Hours, Mins, Seconds.