问题
I need to calc the time between two dates. If column V is blank, then look at column X; now return the difference btw the returned value (either X or V) and the date in column S.
回答1:
Maybe
=IF(ISBLANK(V2),S2-X2,S2-V2)
In words: If cell V2 is blank, calculate S2 minus X2, otherwise calculate S2 minus V2.
Adjust to your needs.
回答2:
For row 1, you could use
=IF(OR(ISBLANK(V1),V1=""),X1-S1,V1-S1)
It is extremely important to note that blank and an empty string behave differently. This shows up once and again, and it is a source of quite a bit of trouble. Any formula or code should account for this, according to the demands of the task.
In addition, you have to select an appropriate number format. For instance, use Custom, and in Type use dd"d" hh:mm.
来源:https://stackoverflow.com/questions/27663891/an-excel-formula-using-is-blank-and-is-not-blank-based-on-two-columns