Excel provides a HYPERLINK function for creating hyperlinks in our spreadsheets. The real power behind this function is that it can be used to create dynamic hyperlinks.

We can create conditional hyperlinks by nesting them within an IF function, or create hyperlinks that can find the address to link to themselves by embedding Lookup or Text functions within them. This helps us to create automated and error resistant spreadsheets.

The HYPERLINK function is written as;

*=HYPERLINK(link_location, [friendly_name])*

**Link Location:** This is the cell, file or webpage that you want to link to. A # symbol can be used when referencing a cell within the active workbook.

**Friendly Name:** This is the text used as the hyperlink text that users will click on. This information is optional, and if omitted the text used by the links destination will be used.

If you are creating a static hyperlink to another file you should use the Hyperlink button on the Insert tab. The HYPERLINK function is here for impressive dynamic links.

In this example we want to create a hyperlink in column C of our table of contents. The user can then click the hyperlink to jump to the sheet of the country entered in column B.

The formula below uses the CONCATENATE function to join together the hash symbol, the countries name from cell B3, and A1 preceded by the exclamation mark. By referencing cell B3, when copied, this function would take the user to the correct sheet.

=HYPERLINK(CONCATENATE(“#”,B3,”!A1″),”Go to Page”)

Fortunately Excel has a full repertoire of fantastic date functions. Here are five of the best.

The TODAY function is used for a lot of good date calculation work. It returns the current date using your system clock. This is essential for so much of what you may be trying to do in Excel. As the date changes every day, this function is the technique for getting your Excel features or formulas to keep track of it so that they work every day.

It is written as below;

*=TODAY()*

No information is needed by this function as it gets what it needs from your computer.

The video below shows the TODAY function being used to highlight dates older than 30 days.

The NETWORKDAYS function is used to calculate the number of working days between two dates. It is written as;

*=NETWORKDAYS(Start Date, End Date, [Holidays])*

Holidays is optional and does not need to be supplied to the function. Holidays should be entered as a range of cells on your spreadsheet that contains the holidays.

For example, the NETWORKDAYS function can be used to calculate the number of working days between the date an order was taken and when it was dispatched.

*=NETWORKDAYS(B2,C2)*

The EDATE function returns the date a specified number of months before or after a start date. Its syntax is;

*=EDATE(Start Date, Months) *

For example, the EDATE function can be used to calculate the probation period of an employee. The formula below returns the end date of a 3 month probation period.

*=EDATE(C2, 3)*

The WORKDAY function returns a date a specified number of workdays before or after a start date. It is written as;

*=WORKDAY(Start Date, Days, [Holidays])*

For example, this function has been used in my Gantt Chart template. It calculates the finish date of a task given a start date (D7) and a tasks duration (C7). Holidays have been provided by using the nonworking range name.

*=WORKDAY(D7,C7,nonworking)*

Find out about the Excel Gantt chart template.

The DATEDIF function is used to calculate the difference between two dates. The difference can be returned as years, months or days.

This function is not documented in Excel (weirdly?) so when entering it into a cell you will not get any information. However its syntax is;

*=DATEDIF(Start Date, End Date, Interval)*

The interval should be entered as a string so using double inverted commas. Use the first letter of the interval you wish to return e.g. “y” for years or “m” for months.

The interval can also be entered as a combination. So for example “ym” would calculate the number of months between the two dates excluding years. This returns a result as if the dates were in the same year.

The DATEDIF function could be used to calculate a person’s age. For example, the formula below will calculate the age of a person as of the current date, where cell B2 contains the person’s date of birth.

*=DATEDIF(B2,TODAY(),”y”)*

If you wanted to return the persons age as how many years and months old they are we could use the formula below.

*=DATEDIF(B2,TODAY(),”y”)&” years “&DATEDIF(B2,TODAY(),”ym”)&” months”*

This formula uses the ampersand to concatenate two DATEDIF functions and some text.

Learning Excel is easy with Computergaga – browse our website to find out more

]]>The SUMPRODUCT function is used to multiply the values of multiple arrays and then sum the totals. However it is capable of so much more amazing feats. It truly is one of those hidden gems waiting to be discovered.

In this example the SUMPRODUCT function is being used to count the number of orders in the list shown below.

This list has been formatted as a table providing many benefits. One of the benefits is the ease of referencing the necessary columns within a formula (Find out more about tables in Excel).

To use the SUMPRODUCT function to count records we will enter it as below.

=SUMPRODUCT((condition 1)*(condition 2)*(condition 3))

Each condition, or array, is enclosed within its own set of brackets. The multiplication operator (*) is used to apply the AND logic between each condition.

For example, the formula below will count all the orders by the salesperson Peacock (J9), and for the product Tofu (K9).

An area where SUMPRODUCT demonstrates its flexibility over alternatives such as COUNTIFS, is its ability to handle OR logic between conditions.

If we want to count all the orders by the salesperson Peacock (J9), and also the Salesperson Taylor (J10) we could enter the formula below. The Plus operator (+) has been used to create the OR logic between conditions.

The SUMPRODUCT function can handle many more conditions if necessary. When you get to grips with it you will feel like no data analysis is out of your reach.

Cue the DGET function. A very powerful Excel function that will retrieve data from a record without the limitations of Vlookup. Advantages of using the DGET function include:

- It can retrieve data from a column to the left of the column you searched within.
- It can lookup data based on multiple conditions.
- It can handle both AND and OR logic.

The DGET function is a database function, a group of very powerful functions for analysing large tables of data. (More Excel training – See more on Database functions in Excel).

The DGET function is written as below;

*=DGET(database, field, criteria)*

Database |
The range of cells where you want to search for and retrieve the data. The first row must contains the headings for each column. |

Field |
The column containing the information that you want to return. This can be entered as the column’s index number i.e. 5, or you can use the column heading enclosed with quotation marks e.g. “Salesperson”. |

Criteria |
The range of cells that contain the conditions for your search. The first row must contain the column heading. |

The following formula has been entered into cell J3 in the image below it.

It looks within range A1:G800 and returns whatever data is finds in the first column. The criteria for the search is stored in range I2:I3. I2 contains the column heading of Order ID. This exactly matches the one found in row 1 of the database. Cell I2 contains the content to search for, in this case 11248.

=DGET($A$1:$G$800,1,$I$2:$I$3)

The #NUM error message is displayed if the DGET function finds more than one record that meets the search criteria.

The #Value error message is shown if no records were found matching the search criteria.

The DGET function is not case sensitive.

To find the difference between two dates in months we can use the MONTH function in Excel. The formula below finds the number of months between the date in cell A1 and the date in cell B1.

=MONTH(A1)-MONTH(B1)

The MONTH function extracts the number of the month in the year. So for example, with the 12/08/2011, the MONTH function would return 8.

This formula subtracts the month returned from one date from the month returned from the other date. It is a basic calculation that does not take into account dates that span multiple years.

If the two date involved in the calculation span multiple years then the formula needs to be adapted. The formula below can be used to find the difference between two dates, that span multiple years, in months.

=IF(DAY(B1)>DAY(A1),0,-1)+(YEAR(A1)-YEAR(B1))*12+MONTH(A1)-MONTH(B1)

This formula can be broken into two sections:

The second section includes the (YEAR(A1)-YEAR(B1))*12+MONTH(A1)-MONTH(B1).

The YEAR function is used in the same way as the MONTH function. It finds the difference between the two years and multiplies it by 12 to get the answer in months. The difference in months is then added to this total.

This is fine, however it does not taken into account the day of the month. For example, this formula would produce the answer of 1 months difference between the dates of 30/12/2010 and the 02/01/2011. When really there is only 3 days difference.

The first section of the formula; IF(DAY(B1)>DAY(A1),0,-1)+ is used to check if the day of the past date is greater than the day of the more recent date. If it is then the number of months is subtracted by 1, and if it is not then there is no change.

This last example demonstrates the CONCATENATE function being used to create a text that shows the number of years and months between two dates. The results would show 1 years 3 months.

=CONCATENATE(YEAR(B1)-YEAR(A1),” years “,IF(MONTH(A1)>MONTH(B1),0,MONTH(B1)-MONTH(A1)),” months “)

The YEAR and MONTH functions are used again to find the difference. The IF function is used to check if the number of months of the older date is greater than the number of months in the more recent date. If it is then the number of months is 0, and if not it needs to be calculated.

We can use the Data Validation tool with a formula to stop duplicates from being entered by the user. In this example we want to prevent duplicates from being entered into column A.

- Select the whole of column A by clicking the column header
- Click the
**Data**tab on the Ribbon and click the**Data Validation**button - Click the
**Allow:**list arrow on the Settings tab and select**Custom**

- Enter the following formula in the
**Formula**box

The COUNTIF function is used to count how many times the value just entered appears within column A.

Cell A1 is fixed to signify the start of the range, and the end of the range will automatically expand as more values are entered.

The Data Validation tool checks to see if the value has occurred only once. If it hasn’t then the entry will be prevented, and an error alert will be displayed to the user.

- Click the
**Error Alert**tab. Type “Duplicate Entry” in the**Title:**box and “You have entered a duplicate entry.” in the**Error message:**box

- Click
**Ok**

Data Validation will prevent duplicates in Excel. If a duplicate value is entered the following error message will be displayed.

However, if the list is updated often with new records or columns of data, then the named range needs to frequently be updated also. This is an irritating and time consuming role, so this post aims to solve that problem by making the named range grow automatically when new rows and columns are added.

I was reminded of the brilliance of this feature just yesterday when I was asked by a company how they could get their formulas to include any new rows of data automatically. They had various formulas and PivotTables running on a large list of data to perform sales analysis. This data is frequently updated as more sales are made.

I ended up using the method below and had the formulas and PivotTables use the dynamic named range for their data source.

- Click the
**Formulas**tab on the Ribbon - Click the
**Define Name**button from the Defined Names group - Type a name for the named range. The name cannot include spaces or start with a letter

- Click in the
**Refers to:**field and enter the formula below

=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),COUNTA(Sheet1!$1:$1))

Change the references to cells, columns and rows in the formula to those required in your spreadsheet.

- Click
**Ok**

The named range is created. It does not appear in the Name Box list, but it can be used by typing its name into the Name Box.

The formula uses the OFFSET function to make the range dynamic. Let’s have a closer look at how this works.

- Sheet1!$A$1 is used as a starting cell for the range. This cell should be the cell in the upper left corner of your range
- The two zeros ensure that the range does not move from its base reference.
- The COUNTA(Sheet1!$A:$A) function makes the height of the range dynamic. It is used to count the number of rows that are not blank. The OFFSET function then uses this for the height of the range. Whenever a new row is added, the COUNTA function recognises it and tells the OFFSET function.

The COUNTA(Sheet1!$1:$1) function is used to find the width of the range. This ensures that new columns are included in the named range.

Create dependent drop down lists in Excel

Format data as a table in Excel