Suppose you have a file with a list of student names and the number of votes they received in the student council election. Now assume that, for whatever reason, you can’t or don’t want to sort that list to determine the top 5 vote getters. So you are looking for create a formula that returns a column of student names with the top 5 votes.

Assume your worksheet has the number of votes in Column A starting in Cell A2 through A100, the corresponding student name in Column B starting in Cell B2 and running through B100, and you would like the list of top 5 votes in Column D starting in Cell D2.

In this case, the formula would be:

**=INDEX($B$2:$B$100,MATCH(1,INDEX(($A$2:$A$100=LARGE($A$2:$A$100,ROWS(D$1:D1)))*(COUNTIF(D$1:D1,$B$2:$B$100)=0),),0))**

copied down in this case 5 times through cell D6. This formula will work even if there are tied votes between different students.

]]>I came across a similar tip online and while I couldn’t recall ever having had a use for this, I thought it interesting nevertheless.

Suppose your worksheet has text values in the format “firstnameLASTNAME” and the user would like to separate the two names into two separate columns as determined by the case of the text.

The key is to determine where the text switches from lowercase to UPPERCUASE. To do this, you need to use an array formula.

Assuming your firstnameLASTNAME is in cell A1, the following array formula returns the string of text characters started by, and following, the first UPPERCASE letter in the text string:

**=MID(A1,MATCH(1,(CODE(MID(A1,ROW($1:$255),1))>=65)*(CODE(MID(A1,ROW($2:$255),1))<90),)+1,255)**

Remember, since this is an array formula, you should enter it by pressing Ctrl+Shift+Enter.

It returns everything in the cell starting with the first uppercase letter it finds.

Thus, in “firstnameLASTNAME” it would return “LASTNAME” and in “firstnameLastname” it would return “Lastname”.

Assuming that you use the array formula in cell B1, you could then determine the first name by using the following:

=SUBSTITUTE(A1,B1,””) entered as a a regular formula, not an array formula.

]]>There is no conceivable way that I can improve on this post from Chandoo.org, so I am just going to link to it here:

]]>Not often used since I typically do not work with multiple columns of related data (i.e., multiple columns of Sales figures rather than Sales figures listed down an entire column), but I do come across it on occasion and thought this tip is rather handy.

It saves the step of having to copy and paste the data into a single column which always runs the risk of leaving data out.

(Note: I’m using words in the example below so it’s easier to follow the output.)

In this example, the formula in G1 is:

=INDEX($A$1:$D$4,1+INT((ROW(A1)-1)/COLUMNS($A$1:$D$4)),MOD(ROW(A1)-1+COLUMNS($A$1:$D$4),COLUMNS($A$1:$D$4))+1)

A Named Range would be useful to replace the “$A$1:$D$4” reference if it’s easier to follow.

I kept the “#REF!” output so you can see that the result is when you copy the formula down more rows than is needed. In this case, because the range “$A$1:$D$4” is a 4 x 4 grid, copying the formula down more than 16 rows (4*4=16) will result in the “#REF!” result.

]]>I came across this when I was having difficulty reconciling a sum total against a breakout of the component pieces and realized that my data had blanks associated with numerical data, so in order to double check the reconciliation, I needed a “SumIFS” with blank cells as my criteria.

It took longer than I expected to find a solution, so I wanted to post it here.

In the example below, I want to derive a Sales figure based on the Blank Cells in either Column A or Column A AND Column B.

In this way, you can use the Excel SumIFS function to consider the blank cells as a criteria.

]]>I had been using Excel for decades before I found about this tip.

When you want to repeat the last action that you have just taken, simply select the next cell or range where you want to repeat it and press the **F4** key.

I have found myself using this most often for quickly adding and/or deleting rows or formatting a cell with a particular color (especially useful if I want to highlight cells where I have hardcoded a number or a column reference).

For example, to insert a row with this method, insert a row as you normally would using the mouse. Then, move to the active cell where you would like another row inserted and press F4.

Rinse and repeat as necessary.

]]>Here is a completely under appreciated and therefore, underutilized function in Excel.

The TRANSPOSE function is used to copy data located in a row into a column or copy data located in a column into a row.

This is an ARRAY function, so you will need to hit Ctrl + Shift + Enter after typing it in to add those curly braces “ { } “.

For example, enter the following data into cells:

B5 – apple , B6 – pear, B7 – banana.

Now highlight cells D5:F5 – the location where the results will be displayed.

In the formula bar, type: “TRANSPOSE(“ and select cells “B5:B7” to complete the formula.

Press Ctrl + Shift + Enter to enter the function as an array formula.

The data in cells B5:B7 should now appear in cells D5:F5.

When you click on any of the cells from D5:F5, the complete function:

{ = TRANSPOSE ( B5 : B7 )} appears in the formula bar above the worksheet.

]]>

The fastest way to find something in a worksheet is to use Excel’s “Find” command.

Go to Edit > Find & Select > Find. You can also use the keyboard shortcut CTRL+F. Using either of these and clicking “Find Next” will take you to the next matching cell of your search query.

But what if you want to find the *last* matching value??

Instead of having to click through each one to get to the end, a simple trick is to select a cell *BELOW* the range you want to search, then hold down the **Shift** key while using the “Find” command.

Clicking the “Find Next” button while holding down the **Shift** key will start at the **LAST** matching item and search backwards to the top of your worksheet.

Suppose you wanted to create a weekly agenda spreadsheet in which you not only wanted the days of the week across the columns, but the calendar dates as well (i.e. Tuesday, October 16, 2012 would appear as Tuesday (16).) But rather than having to update the dates each week, you want to make them dynamic so that they would always show the correct dates.

You know that you can use __=TODAY()__ to get today’s date.

But how can you determine the date for Sunday of the current week?

Let’s use October 16, 2012 for an example.

There are two functions that you will need to use: TODAY() and WEEKDAY().

To get the date for the Sunday of the current week, use the following formula . . .

**=TODAY()-WEEKDAY(TODAY())+1**

To understand what this formula is accomplishing: **TODAY()** gives you today’s date (in this case October 16, 2012) and **WEEKDAY()** returns the weekday number (where Sunday = 1, Monday = 2, Tuesday = 3 . . . . etc.).

Therefore **=WEEKDAY(TODAY())** returns the week day of today.

For October 16, 2012, the weekday would be 3 (Tuesday).

When you take today’s date and subtract today’s weekday you get the date for the previous Saturday. (i.e. Tuesday, October 16, 2012 – 3 gives you Saturday, October 13, 2012).

Now, simply add 1 to get Sunday’s date: __=TODAY()-WEEKDAY(TODAY())+1__

If you prefer to start with Monday’s date, simply add 2 to the formula rather than 1:

__=TODAY()-WEEKDAY(TODAY())+2__

This is a quick and dirty formula trick to search for an item in a list and get the 2nd, 3rd, 4th . . . occurrence of that item found.

As you probably know, VLOOKUP (as well as MATCH and HLOOKUP) only gives you the *first* occurrence of that item in a list.

This formula uses the trick of searching for an item and returning the row number of the of 2nd, 3rd, 4th . . . occurrence of that item.

It your list of items are in Column “A”, the item that you want to search for is in cell “D3” and the listing of occurrences are in Column “D”, then you can easily set of your spreadsheet in the following manner: