VBA
New Member
- Joined
- Jan 19, 2009
- Messages
- 39



I'm having a bit of trouble with date and time. Let's say my sheet looks like this:

I want to calculate the intermediate hours, thus between one given date/time (the time belongs to the date above) and the previous one. I figured I could just do
= (B1-C1)*24 + B2-C2
But apparently, date and time collide. Excell is quite confused which format to pick: it has to be either date or time...
I solved this by setting row 3, 4 and 5 on "general format" and using the following formula's
row 3) =B1-C1
row 4) =(B2-C2)*24 sometimes negative, *24 as the format time reduces to percentages of the day when set to general.
row 5) =B3*24+B4
This works.
I do wonder though, is it possible to make it into one if-statement? It seems a bit elaborate now...
Greetings.