Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Power excel 2016 with mrexcel Master Pivot Tables, Subtotals, Charts, VLOOKUP, IF, Data Analysis in Excel 2010–2013 (Bill Jelen) (z-lib.org).pdf
Скачиваний:
4
Добавлен:
14.08.2022
Размер:
49.75 Mб
Скачать

220

POWER EXCEL WITH MR EXCEL

 

 

 

STRANGENESS OF TIME FORMATTING

Problem: Something is strange with time formatting. I can’t total my time sheet to show 40 hours.

Strategy: Do you remember when you had a date and you formatted it to show only one element of the date? All of the cells in column C contain the exact same value, but they have a different numeric format.

In cell C4, you are asking Excel to show you only the day, so it gives you a 3. That is exactly what you asked for. You didn’t ask to see years or months, so it did not include that value.

In contrast, consider the following time sheet.

Everyone looks at cell H15 and says that something is wrong. It should be 40 hours, not 16 hours.

But Excel is doing the same thing here that it did back in Figure 546. You formatted H15 with the H:MM format, so Excel threw out the date portion of the value. Think about it. 40 hours is really 1 day and 16 hours. All that you are seeing in H15 is the 16 hours. You didn’t ask to see the day.

Since time tracking is a common activity in Excel, there must be a solution.

Figure 546 Control the display of a value using format codes.

Figure 547 The payroll department will save on salary expense here.

There is, but it is not easy to figure out.

Select cell H15. Use Ctrl+One to Format Cells. Select the Time category. Scroll down until you see the time format with 37:30:55.

This will show your time as 40:00:00.

Figure 548 Choose 37:30:50 to display hours in excess of one day.

In reality, you have more flexibility if you use the Custom category. Choose the 37:30:50 and then click on Custom. You will see the code is [H]:MM:SS. The square brackets are the code to tell Excel that you want to see all hours, not just the hours in excess of whole days.

Figure 549 Forty hours.

PART 2: CALCULATING WITH EXCEL

 

221

 

 

 

You can extrapolate the following custom codes:

 

 

[H]:MM is the format you want for the time sheet.

 

 

You can also display the absolute number of minutes or sec-

 

 

onds using formats of [D] or [S].

 

 

 

Figure 550 3AM is 180 minutes past

 

midnight.

CONVERT TIME TO DECIMAL HOURS

Problem: I bill my clients hourly. How can I convert Excel times to decimal hours so that I can do my billing?

Strategy: Multiply the Excel by 24 to come up with a decimal number of hours. You can them multiply the hours by the hourly rate to calculate the billing.

2

Figure 551 Multiply times by 24 to get hours.

CALCULATE WITH TIME

Problem: I need to do calculations by hour.

Strategy: There are functions HOUR, MINUTE, and SECOND to break a time into components. There is a function TIME(Hour,Minute,Second) to put time back together.

Figure 552 Time calculations.

222

POWER EXCEL WITH MR EXCEL

 

 

 

ENTER MINUTES AND SECONDS

Problem: I have to keep track of test data in minutes and seconds.

Strategy: This is much more difficult than anyone would think. Say that the first test took 1 minute and 30 seconds. You try entering 1:30 in a cell.

Figure 553 What does the value in B2 really mean?

The result looks OK. However, when you click on the cell, you see that Excel has interpreted the entry as

1:30 AM, which is 1 hour and 30 minutes instead of 1 minute and 30 seconds.

Figure 554 Excel assumed you meant 1 hour and 30 minutes.

To enter minutes and seconds, you have to enter 0:01:30. This seems like a frustrating waste of extra keystrokes.

If you have entered a column of time in the wrong format, you can correct it with

=TIME(0,HOUR(A2),MINUTE(A2)). Alternatively, multiply the times by (1/60).

Figure 555 Two ways to correct time that has been entered incorrectly.

CONVERT TEXT TO TIME

Problem: I have a spreadsheet where the times were imported as text.

Strategy: Use TIMEVALUE to convert the text to time. However, the text dates have to be in the correct format.

Below, text entries in column A are converted with TIMEVALUE in column B. Some formats work. Others do not.

PART 2: CALCULATING WITH EXCEL

223

 

 

Figure 556 Results of TIMEVALUE.

One common issue is that TIMEVALUE requires a space between the time and AM or PM. If you have a lot of text like cell D11 above, try using Find and Replace to change “AM” to “ AM” and “PM” to “ PM”.

Another problem: both TIME and TIMEVALUE will not return a number greater than 23 hours, 59 min- 2 utes, and 59 seconds. In row 8 above, the entry in interpreted as 123 hours and 40 minutes. This is 5 days

and 3 hours. TIMEVALUE figures this out, but then truncates the 5 days and only returns 3 hours. If you had data entered in this format, you could use a formula such as: =LEFT(A8,FIND(“:”,A8)-1)*(1/24)+MID (A8,FIND(“:”,A8)+1,50)*(1/1440).

CAN EXCEL TRACK NEGATIVE TIME?

Problem: I keep track of comp time for employees. If employees work more than 8 hours, this time gets put into a bank so that they can work less time on another day. The company will generally let people go a few hours into the negative. But Excel completely freaks out when my formula results in a negative time.

Figure 557 Cell E6 is -2 hours, but Excel refuses to display the value.

Strategy: The solution to this problem seems bizarre. You should make this change only on a worksheet that doesn’t contain any existing date values.

Excel for Windows stores dates as the number of days elapsed since January 1, 1900. Excel for the Macin- tosh stores dates as the number of days since January 1, 1904. In case you are sharing files with a Mac,

Excel has a setting which indicates that dates should be displayed in the 1904 system. Basically, Excel will adjust the date by 1,462 days when you choose this system.

In the figure above, -2 hours works out to 10 p.m. on December 31, 1899. Excel simply won’t display dates from 1899. But if you go 2 hours before January 2, 1904, you happen to have a date and time that Excel is willing to display!