WEEKDAY

Summary

Weekday is a very useful little function. Quite simply, it works out which day of the week a date represents.

Given that dates are simply formatted numbers, it can be used against any cell that contains a number. But it's probably safest to only apply it to cells formatted as dates.

The formula returns a number to represent the day of the week (Monday–Sunday). The second argument in the formula determines what that number represents.

If the cell being referenced contains any time within a given date, it will be treated as that date and the formula will correctly bring back the correct number.

Note that the formula yields an incorrect result for dates between 1 January,1900 and the non-existent 29 February, 1900 owing to a purposeful Excel bug.

Syntax

=WEEKDAY(Cell,Number)

Cell is the cell containing the date in question.

Number can take the value 1, 2 or 3, and controls how the number comes back.

  • 1: This returns a number between 1 (Sunday) and 7 (Saturday)
  • 2: This returns a number between 1 (Monday) and 7 (Sunday). I always choose this option
  • 3: This returns a number between 0 (Monday) and 6 (Sunday).

Examples

If cell A1 contains the value 5 July, 2011, then:

=WEEKDAY(A1,1) will bring back 3

=WEEKDAY(A1,2) will bring back 2

=WEEKDAY(A1,3) will bring back 1.

Calculating basis points

Here's a handy spreadsheet to help you calculate basis points, and prorate their charge as necessary. Simple, but useful.

Converting a column of data into a row

If you have a column of data and want to instead display this across a single row, you can do so via the Paste Special tool.

First, copy your column (CTRL+C or via the Copy button). Then select the leftmost cell into which you want your row of data to appear. On the Home ribbon, hit the little down-arrow beneath the Paste button and hit Transpose. The data will be pasted across that row.

If you simply want the values (rather than the formulae), instead of hitting Transpose, hit Paste Special… and further options will allow you to combine a pasting of values with the transpose function.

If you need to copy formulae while retaining their reference points, this takes a little trickery. First, switch to formula view by hitting CTRL+` (the key above the tab key). Highlight your column of formulae and do a find and replace of "=" with "#=". This will replace the "=" at the beginning of each formula with "#=", and will mean that Excel no longer regards these as formulae.

Now do your Copy/Transpose as detailed earlier in this post. And now highlight your newly transposed data and do a find and replace of "#=" with "=". Toggle back to values view by hitting CTRL+`, and you're done.

Cute.

Custom Views: a little-known treasure

I stumbled upon Custom Views in Excel by accident a number of years ago, in the pre-ribbon era. I use them very occasionally, but when I do, they offer lots of power and options.

Custom Views allow you to have multiple visual settings for a worksheet, and for these to be selected depending on what you're trying to achieve—or who's accessing the information—without having to hack around at your underlying data. They can be used to control the following features:

  • Print settings
  • Hidden rows and columns
  • Column filters.

Here's what you do.

Once your data is complete, set the above attributes according to how you'd like your View to look. Hide whatever columns and rows are redundant for that particular function or audience, filter the columns as you need them to be filtered, and configure your print settings appropriately.

Once you're happy that the spreadsheet looks as you'd like it to look under that View, Select the View ribbon and hit Custom Views and hit Add.

Give your view a name that makes sense to the audience and select which attributes you'd like the view to respect, and hit OK.

Repeat these steps to create as many views as you need.

If you want to enable a View, then you do so via the same menu. It would be useful if there were a dropdown below the button allowing quicker selection (similar to the many such dropdowns beneath the Home ribbon), but if you need quicker access, then it's relatively simple to record a macro and assign it to either a button or a shortcut.

Custom Views are useful for any type of data: risks and issues, defect lists, employee lists, invoice lists etc. They're useful to show multiple cuts of the same data to a single individual: open risks, outstanding invoices, high-priority open defects.

But they come into their own when showing different cuts of the same data to different groups of individuals. Management want to see different aspects of risks and issues than do operational staff. HR need to see different information about employees than the heads of each business area. Hiding columns and filtering out rows is particularly useful in this regard.

A word of warning: Custom Views are not compatible with Tables. So if you have a formatted table anywhere in your workbook, you won't be able to use Custom Views. Such is life.

Risks and issues registers in Excel

There are two big problems with most risks and issues registers:

  • They’re difficult to read
  • They’re difficult to maintain.

Let’s start with the readability. Usually, they’re a lifeless grid in a tiny font with lots of columns and, depending on your project/programme, lots of rows. There is nothing to distinguish between the rows other than the contents of the eight-point type in each of the cells. Risk or issue titles are unnecessarily verbose, and it’s often not clear what an item represents by reading it.

To solve this problem, I think it's useful to include a "Headline" column in 14-point bold. Maximum of ten words to give a high-level description of what the entry is all about. People will read it and say “Ah, yes. I know that one”.

Next, make sure all of the columns are absolutely necessary. Nugatory columns are a pain to fill in, and deflect from the important columns when viewed.

Use 90° text alignment for the short fields (such as who raised it and who it's assigned to) to save width for the columns containing important textual information.

Now some pointers to make your registers more manageable.

Don’t hive off closed items. Just close them in the status field. It’s important that you keep them for posterity and completeness. Use Excel’s Custom Views to make sure you don’t see them when you don't need to. Keeping data in a single location is important in Excel, partly to make your spreadsheets easy to use, but also to ensure that they're easy to analyse.

Have a single register to house both risks and issues. This is a biggie that I can’t stress enough. Although some of the columns for each register are subtly different, there are quite a few that are consistent between the two. Keep two registers and your reference numbers get cumbersome, and cutting and pasting from one to another when risks become issues is a pain.

If a column for risks is sufficiently similar in nature to an issues column, then combine the two. If needs be, have three heading rows, one for risks, one for issues and one for a combined view, and use Custom Views to hide the two title rows that are redundant for a particular view. If you’re showing risks, hide the issues and combined titles, for example.

If columns are being used to determine the Custom View via filtering (e.g. Status: Open; Type: Risk), then hide these two columns in that view—they’re redundant. Instead, include a cell above the title row saying “Open risks” that can be displayed for that view. For each view, have a dedicated row above the title rows purely for this function, summarising the view. This can be printed on every sheet through repeated titles. And if you want, you can succeed it with the number of records in the filter.

And below are a few other points worth making.

Unless you’re using some shared web interface, use Excel. Don’t consider anything else. Excel is perfect for data like this. Word is appalling; PowerPoint worse.

For the risk or issue titles, word your items as statements of fact. Risks should be phrased as if they’ve happened. Issues similarly, because they have. “There is no environment available for performance testing”, for example, is the wording whether it's a risk or an issue.

Keep update summaries brief, and archive old updates into a separate, hidden column in four-point. This is for audit purposes and is rarely referenced. Its font can be increased as and when you need to read it.

By combining your risks and issues, you can have generic reference numbers that support both, ones that never need to change.

Build Custom Views for: open risks; open issues; open items; all items. You can add more complex views if necessary, such as: imminent risks; high-impact issues; escalated items.

Use conditional formatting to work out how to colour items, but only colour the rating cell and make it narrow. Colouring the entire row makes it difficult to read and draws the eye too much.

Here's an example.

Analysis principle: keep your data consistent and together

One of the most important principles for managing data in Excel is this: keep your data consistent and together.

Excel is vast. In the 2007 version, each sheet contains enough cells to store three pieces of information about every person on the planet. So it's tempting to use its vastness to store one thing here, one thing there. Put your risks on one sheet, issues on another; move your closed defects on to a separate sheet to avoid cluttering the list.

A word of advice: don't.

Excel is at its most powerful when your data is consolidated. If your risks and issues are in a single list table, you can analyse them more easily. If your closed bugs are interleaved with your open ones, then it will be much easier to provide bug metrics. Once you start creating multiple lists or tables, you lose all of this power.

If things are sufficiently different so as never to need to be analysed together, then that's fine—keep them apart. But if there's ever a chance that you'll need to analyse them together, then keep the data together.

Many people complain about data being littered: I only want to see my open defects; I only want to see open risks assigned to me. Don't accept this argument.

At the higher level, use Custom Views to show different cuts of data. Custom Views allow you to apply filters and hide columns, and to save this view for future use. So you might have different views for risks, issues, items (everything), open risks, open issues, open items. At a lower level, users are free to use filters to select everything assigned to themselves, for example.

One final piece of advice: if at all possible, avoid having columns headed with the same type of thing. An example might be dates. If you're storing raw data for analysis purposes, try not to have a column representing each of a number of years (column B contains 2011figures, column C contains 2012 figures etc.). Instead, create multiple rows to store the data, and have a column headed "Year".

There will be more tutorials on how to analyse the data at a later date. But first, it's important to embed the principle that enables that analysis.

Starting out with formulae in Excel

There are three posts you should read, in this order, if you're starting out with formulae in Excel.

Get in touch if you need any help.

F2: the most useful key in Excel

F2 is probably the most useful key in Excel. Below's a description of what it does.

It toggles between Edit mode and Enter mode. If you're navigating across the spreadsheet, hit F2 when you've settled upon a cell, and the cursor will show that you're now editing its contents. The left and right arrow keys will move within the formula or value as opposed to continuing to move you around the spreadsheet.

But here's the neat trick. Imagine you hit F2 and you're in the middle of editing a formula. If you need to insert a cell reference, hit F2 again. This will move back into Enter mode, allowing you to use the cursors to choose the cell or range that you're looking to reference.

Below is an example.

=COUNTIF(A1:A4,1)

Imagine you've got that formula in cell C1. But instead of counting the number of instances of the value 1 in cells A1 through A4, you instead meant to check the equivalent cells in column D.

Go to cell C1 and hit F2. The cursor will start flashing at the end of the closing bracket. Hit Left three times and it will move to the position before the comma. Hit Backspace five times and you'll get rid of your reference to column A. Now hit F2. Visually, there will be no evidence of you having pressed F2, apart from a tiny change in the bottom-left corner of your screen. Just below your sheet tabs, the word Edit will change to the word Enter.

Now you can use your cursor keys (together with Shift and CTRL if you like) to select your range in column D. Hit Enter and your formula is complete.

I've found that few people know about this toggle, and people end up typing all cell references once they're editing a formula that already exists.

Number to text converter: most useless spreadsheet ever

I can’t remember why, but I set myself a personal challenge some time back to create a spreadsheet that could convert numbers to text.

Here it is. Type in a number between 1 and 999,999 in the red cell and it will write it out in words in the blue. English style, not American, so the ands are included.

When you break it down, there are only 29 words used in the numbers below a million: the digits (one through nine), the tens (ten, twenty, … , ninety), the extended teens (eleven, twelve, … , nineteen), together with and, hundred and thousand.

I wrote the text for each of the sets of numbers next to their numeric equivalents for the purposes of VLOOKUPs. I then I parsed the number entered by the user, also figuring out its length. And then, for each of the six digits, I used logic to determine what to display for that digit.

And here is the logic for that fourth digit from the right, the most complex of the bunch.

=IF(Working!A15>=4,IF(OR(Working!D15=0,Working!C15=1)," thousand "&IF(AND(Working!E15=0,Working!F15=0,Working!G15=0),"",IF(Working!E15=0," and","")),VLOOKUP(Working!D15,Working!$A$2:$B$10,2,0)&" thousand"&IF(AND(Working!E15=0,Working!F15=0,Working!G15=0),"",IF(Working!E15=0," and",""))),"")

Below is the logic in English.

  • If the number's length is greater than or equal to four, then this digit comes into play. If it doesn't, then return a blank
  • If the fourth digit from the right is a zero, then you just need the word thousand, because there's nothing else to count. 110,000, for example is spoken one hundred and ten thousand. The ten would have been picked up by the logic for the fifth digit from the right, so we just need to say thousand before we move to the last three digits
  • Now if the fifth digit from the right is a one, then logic therein figures out which extended teen it is, and this is derived within the logic representing that digit. So as with the bullet above, in this instance the only thing to say is the word thousand
  • If the three subsequent digits are all zero, then there's no need to say and after the thousand. Otherwise, there is (in British English, at least)
  • Now we look up the digit itself to bring back its text equivalent (2 becomes two, for example)
  • If the third digit from the right is a zero and the number isn't an exact thousand, then you'll need an and. 1,023, for example, is one thousand and twenty-three

All in all, it took me about an hour. It was a bit of fun. And it seems to work. Give it a go.

Check which entries of one list appear in another list

Challenge: find out which entries in one list appear in another list.

This problem comes up time and time again in Excel. In fact, it's probably the most common challenge that people come to me to solve. Here's how to solve it.

Let's say we have a list of car manufacturers in column A. And a list of US presidents in column D.

Lists

And in column B, we want to flag whether the car make appears in the list of US presidents. Enter the following formula in cell B2.

=IF(ISNA(VLOOKUP(A2,D:D,1,0)),"No","Yes")

This will return "Yes" for rows 2 and 4, as Ford and Lincoln both appear in the list of US presidents. And it will return a "No". for Chrysler and Toyota in rows 3 and 5.

The formula can then be copied down the full length of the first list to perform similar checks for the other car makes.

Here's an explanation of the formula, from the inside out.

  • VLOOKUP(A2,D:D,1,0): this looks up A2 (Ford) in column D (the list of US presidents), and brings back the data from the first column in the look-up range—or in other words, it will bring back "Ford". If the lookup fails, then it will bring back #N/A (meaning "not applicable")
  • ISNA(VLOOKUP(A2,D:D,1,0)): the ISNA checks whether the VLOOKUP has resulted in a "not applicable" answer. So for the rows for Ford and Lincoln, it will bring back the value "FALSE" (i.e. it brought back a value as opposed to a "not applicable"); and for the other rows, it will bring back the value "TRUE"
  • IF(ISNA(VLOOKUP(A2,D:D,1,0)),"No","Yes"): finally, we wrap the check in an IF statement. If it's true, then the answer is "No"—i.e. the entry is not in the list; if it's false, the answer is "Yes".

Hope that makes sense. Let me know if you need any help with this.