Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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б
Скачать

212

POWER EXCEL WITH MR EXCEL

 

 

Gotcha: You want the number of days. Excel will guess that you want the answer as a date. After entering the formula, change the number format back to numeric.

Additional Details: The title in cell A1 is created us- ing TODAY as well. The formula is =”Invoice Aging as of “&TEXT(TODAY(),”MMMM d, YYYY”).

Additional Details: The icons in column C were added us- ing Conditional Formatting. You will read about icon sets in

Part IV of this book. The accountant in me could not resist analyzing the result, even though this data is completely fic-

titious!

Figure 527 Use TODAY() to calculate days away.

You might want to categorize the receivables into 30-day buckets. The formula in D4 will show 30 for any invoices that are between 30 and 59 days old. The formula is

=INT(C6/30)*30. Say that you divided column C by 30 and then took the INT of the result. Everything from 0 to 29 would be classified into Bucket 0. Everything from 30 to 59 would be classified as Bucket 1. I multiply that bucket number by 30 to provide a better name for each bucket. To get the plus sign to show, use a custom number format of 0+.

Figure 528 Grouping receivables into buckets.

NOW, OR TODAY?

Problem: Why did you use TODAY() in the previous topic. Isn’t this the same as NOW()?

Strategy: The NOW function will return the date and time that the workbook was last calculated. Workbooks are calculated when they are opened, when you enter a value in the worksheet, or when you press the F9 key. In other words, they are calculated a lot.

If you enter NOW in a cell, it will generally show the current date and a fairly recent time.

The TODAY function is similar to NOW, except it returns only the current date. In many cases, the TODAY­ function is more appropriate for calculating the number of days between today and a deadline.

Below, cell B1 contains a due date. If you calculate =B1-NOW(), Excel will say that it is 12.561 days away. If you calculate =B1-TODAY(), Excel will say that it is 13 days away. If you go into work on Monday, then most people would say that Wednesday is 2 days away. If you use NOW instead of TODAY then at 9 a.m., Excel would say that Wednesday is 1.625 days away.

PART 2: CALCULATING WITH EXCEL

213

 

 

Figure 529 For whole days, use TODAY instead of NOW.

Additional Details: To calculate the current time, you could use =NOW()-TODAY() or =MOD(NOW(),1).

Make sure to format the resulting cell as a time.

FIND THE LAST SUNDAY OF THE MONTH

Problem: I have a column of dates. I need to post-date those dates to the last Sunday of the month. Or,

I need to pre-date those to the first Monday of the month. Or, pre-date the date to the previous Monday, 2 but only if today isn’t already a Monday. Or, post-date to the next Friday, but only if today isn’t a Friday.

Strategy: Use a formula from the table in this topic.

Excel offers a WEEKDAY function that helps you to identify the weekday of the date.

The function historically offered 3 ways to identify the weekday. The traditional method used 1 for Sunday through 7 for Saturday. The return type of 2 used 1 for Monday and 7 for Sunday. The return type of 3 used 0 for Monday and 6 for Sunday. That last return type was great for calculating the “Week Beginning”. You could use =A2-WEEKDAY(A2,2) and all dates would go back to Monday.

Today, Excel offers 7 additional return types, numbered 11 through 17. Here is the tooltip explaining them all.

Figure 530 WEEKDAY now offers 10 return types.

If you sit down to figure these calculations out, you really have to love the brilliance of the return type 3 with its results of 0 through 6. All of the ones that result in 1 through 7 make your formula much harder.

Lets say that you want to roll a date back to Sunday. The date is in A2. If the date happens to fall on a Monday, the WEEKDAY(A2,11) is 1. So, life is simple, you could use =A2-WEEKDAY(A2,11) to roll the Monday back to Sunday. This logic works throughout the week, all the way up through Saturday. The WEEKDAY(,11) of a Saturday is 6, so =A2-WEEKDAY(A2,11) will subtract 6 from the date and you end up on the prior Sunday. The formula falls apart when A2 already is a Sunday. =WEEKDAY(,11) of a Sunday is 7. When you subtract 7 from the current date, you end up a week too early.

214

POWER EXCEL WITH MR EXCEL

 

 

Here you are, with a WEEKDAY function that works 6 out of 7 days. Whenever the WEEKDAY function returns a 7, you need it to be a zero.

Enter the MOD function. Calculate the WEEKDAY, then take the MOD(Weekday(),7). For the numbers 1 through 6, the MOD will be 1 through 6. But for the number 7, the MOD will be 0. Perfect.

For background, MOD stands for MODULO. =MOD(100,7) takes 100, divides by 7, throws out the integer portion, then expresses the remainder as a whole number. 100 divided by 7 is 14 with a remainder of 2.

=MOD(100,7) will give you the remainder of 2.

Are you still reading? This gets incredibly complex. Below are two tables showing all of the formulas that you will need. The tables assume that your date is in A2.

Figure 531 Find the last weekday of the month.

If you need to build “Week of” dates, these formulas will work.

Figure 532 Change the date in A2 to a week beginning date.

If you are in Excel 2007 or earlier, then you are limited to the return types of 1, 2, or 3. The following table uses CHOOSE to add or subtract the appropriate number of days.

PART 2: CALCULATING WITH EXCEL

215

 

 

Figure 533 Back in Excel 2007, WEEKDAY offered less options.

CALCULATE WORK DAYS 2

Problem: We have a big project due on April 15. I need to figure out how many work days until the project is due.

Strategy: If you work Monday through Friday, use NETWORKDAYS. If you have another work week, use NETWORKDAYS.INTL. Both functions allow you to specify a list of company holidays and will factor the holidays into the calculation.

You specify a start date, an end date, and a list of company holidays. Excel will calculate the number or work days including the beginning and ending date.

1. In a blank range in your worksheet, enter the company holidays for this year. Be sure to include the year. Instead of 12/25, enter 12/25/2014. Say that you store this list in I3:I10.

2. Enter the formula =NETWORKDAYS(C3,B3,$I$3:$I$10) in cell D3. Note that the argument con- taining the holidays should be an absolute reference with dollar signs.

3. Copy the formula down for all projects.

Figure 534 Column D counts days excluding weekends & holidays.

The NETWORKDAYS always assumed the weekend is Saturday and Sunday. If you have an alternate weekend, the NETWORKDAYS.INTL function will handle it.