18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part II<br />

Working with Formulas and Functions<br />

Summing times that exceed 24 hours<br />

Many people are surprised to discover that when you sum a series of times that exceed 24 hours, Excel<br />

doesn’t display the correct total. Figure 13.7 shows an example. The range B2:B8 contains times that represent<br />

the hours and minutes worked each day. The formula in cell B9 is<br />

=SUM(B2:B8)<br />

As you can see, the formula returns a seemingly incorrect total (17 hours, 45 minutes). The total should<br />

read 41 hours, 45 minutes. The problem is that the formula is displaying the total as a date/time serial number<br />

of 1.7395833, but the cell formatting is not displaying the date part of the date/time. The answer is<br />

incorrect because cell B9 has the wrong number format.<br />

FIGURE 13.7<br />

Incorrect cell formatting makes the total appear incorrectly.<br />

To view a time that exceeds 24 hours, you need to apply a custom number format for the cell so that square<br />

brackets surround the hour part of the format string. Applying the number format here to cell B9 displays<br />

the sum correctly:<br />

[h]:mm<br />

CROSS-REF<br />

For more information about custom number formats, see Chapter 24.<br />

Figure 13.8 shows another example of a worksheet that manipulates times. This worksheet keeps track of<br />

hours worked during a week (regular hours and overtime hours).<br />

ON the CD-ROM<br />

This workbook is available on the companion CD-ROM. The file name is time sheet.xlsm. The<br />

workbook contains a few macros to make it easier to use.<br />

The week’s starting date appears in cell D5, and the formulas in column B fill in the dates for the days of the<br />

week. Times appear in the range D8:G14, and formulas in column H calculate the number of hours worked<br />

each day. For example, the formula in cell H8 is<br />

=IF(E8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!