To analyse this data they wanted to count how many words were in each cell containing keyword searches. Excel provides many text functions for managing and manipulating the text in the cells of your spreadsheet. The following formula did the job.

**=LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),” “,””))+1**

This formula subtracts a version of the cell without spaces between each word from a version still with spaces. This finds out how many spaces there are. There will be one less space than there are words so the resulting answer has a 1 added to it to find how many words there are.

The Len function is used to find how many text characters are in the cell.

The Substitute function is used to replace the spaces between each word with nothing making one long word.

The Trim function is used to remove any spaces at the beginning or end of the cell content. This cleanses the cells of any erroneous spaces put in by user error, or error on import.

Count the Number of Words in a Cell – Microsoft Excel Tips and Tricks

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.