Excel has new TEXTBEFORE and TEXTAFTER functions. It doesn’t have a TEXTBETWEEN function. Let’s make one.
Category Archives: Functions
Percentage of the Year in Excel
As we get used to the new year we may want to perform some calculations based on the old year. A recent inquiry requested a formula that could calculate the percentage of a year that an employee had been employed. He suggested using an IF function. See the solution below, but it doesn’t involve the IF function.
Rounding to the Nearest 9 Cents in Excel
A client recently requested a formula to round to the nearest 9 cents. This avoids getting to a price point. This is a common requirement in retail businesses. The solution was simpler than I thought it would be.
Custom Function for Age in Excel
Calculating age with years months and days takes several functions to create. Whenever you need multiple functions to calculate an entry you may have a good use case for a custom function.
Last Weekday of the Month in Excel
Excel has a function to find the last day of the month. To find the last weekday of the month you can combine a couple of functions. Here is a custom function that also works.
Custom Function for Days in the Month
Excel’s EOMONTH function is great. Here is a tweak using a custom function to calculate the number of days in a month.
A Cell Reference Custom Function
The formula to return a cell reference is quite long. This makes it an ideal candidate for a custom function.
Date Alignment Trick in Excel
Text alignment in Excel is versatile. If the column isn’t wide enough to display the text, it will display over the next cell. Date and number alignments are not so forgiving. If the column isn’t wide enough the cell with display the ### symbols or the scientific format. Here is a function technique to get around the limitation.
Not So Random Entries in Excel
Sometimes when you are testing or training in Excel you need to create random entries. That is easy to do with the RANDBETWEEN or RANDARRAY functions. What if you wanted to emphasise some entries more than others in the random list created? There is a way.
Avoid the #DIV/0! Error in Excel
DIY Function
If you have the subscription version of Excel you can create your own functions. One that you may want to create avoids the #DIV/0! error.
MIN and MAX and Dates in Excel
Automating the latest date
The MIN and MAX functions can provide easy ways to capture current dates.
One Minute to Excel #26 – Fix AutoSum’s Weakness
Get the right range every time
AutoSum’s cryptonite is a blank cell – it stops AutoSum in its tracks every time.
Here’s how you can avoid AutoSum’s blind spot.
UNIQUE Function and Blank Cells in Excel
Zero in on a problem
The UNIQUE function has a bit of an issue with blank cells, formulas that return blank cells and zeroes.
Identifying if a List has Unique Entries in Excel
A MODE solution
If you need a logical test to determine if a list is unique you can use the MODE function with the ISNA function.
Adding up Text Numbers In Excel Another Technique
If you have a list of numbers that are a text numbers or a combination of text numbers with real numbers there is a technique I covered in this blog post to add them up. But if the range also contains text then the technique won’t work. There is the work around. The solutions below work in the subscription version of Excel. Check the comments section below for a solution for all versions.
The Magical N Function in Excel
Who you calling short?
One reason I like the N function is because it is Excel’s shortest function name. But it has quite a few useful features as well.
Last used column number in a row in Excel
AGGREGATE to the rescue
A while back I posted a formula to find the row number of the last used cell in a column. I revisit the solution to provide the last used column number in a row.
Removing Outliers in Excel
Dynamic array solution
I wrote a blog post a while back about outliers and Excel and I thought I would revisit it thanks to dynamic arrays.
The Excel CONVERT function
Most conversions are easily done
If you need to convert between different measurement systems Excel has just the function for you, called CONVERT.
Working with a Different Working Week in Excel
International functions to the rescue
Let’s say you are transitioning to retirement (lucky you) and you only work four days a week. You have Wednesdays off to play golf. You may still do projects and you need to figure out completion dates based on a start date and working days. Excel can help you.
Switching Reports from Rows to Columns in Excel
TRANSPOSE and OFFSET solution
I was recently helping someone with a budget which they had built vertically, with the months going down the sheet. They then asked to display it horizontally, with the months going across the page. In the latest version of Excel this is straightforward.
Dynamic Arrays and a Book Index
Another solution
Years back when I wrote my Excel book, I had to create an index for the book. I shared the file I used including the macro in this post. Recently I thought dynamic arrays could do much of the work for this.
Financial Year Month in a Pivot Table
Create new column
I wrote an article years ago explaining how to use a related table to handle financial years in Excel Pivot Tables. You can read the article here. If you only want the months in financial year order you can just add an extra column to your table.
Extracting Time from Date and Time in Excel
Another MOD function solution
I had a recent query regarding checking time in a column that had both date and time. There is an easy way to extract time from a date-time combination.
Conditional Format to Display Only the First Entry
In my previous blog post I showed a technique to reduce clutter. The technique used a manual formatting method. Here is the automated version.
You can see my previous post here.
Below is the original table.
We can use a Conditional Format to only display the first entry of each date in the Date column.
Select the range A2:A11.
Click the Conditional Formatting drop down and select New Rule (third from the bottom).
Select the last option in the top section “Use a formula to …”.
In the formula box enter the following formula.
=COUNTIF($A$2:A2,A2)>1
Click the Format button and use the Font tab and change the font colour to White and click OK and then OK again.
The result is shown below.
The formula for a conditional format must return TRUE to trigger the format. The type of formula that you use is called a logical test, which returns either TRUE or FALSE.
The use of the $ signs is very important in this formula. The COUNTIF function counts the number of entries in a range. If the COUNTIF result is above 1 it is a duplicate. In cell A2 the formula will ALWAYS return 1 as it is counting itself.
When creating a formula-based condition across a range you need to build the formula to refer to the top left cell of the range. In this case we need the range to expand as the range extends down the sheet. Hence, we didn’t use any $ signs on the last two A2 references used.
In cell A3 the formula will be.
=COUNTIF($A$2:A3,A3)>1
This is because the A2 references in the original formula had no $ signs, so they will change with the cell to A3. In our case this COUNTIF will return 2 because the date in cell A3 is a duplicate of the date in A2. This will trigger the format.
This formula expands as the range extends. It uses the cell reference of the cell it is in to determine if the entry is the first entry or a duplicate. This formula will not change the format of the first entry, but it will change the formats of any duplicates.
Let’s TRIM with Dynamic Arrays in Excel
Removing problematic spaces with a single function
Dynamic arrays allow you to use a function normally built to handle a cell, with a range of cells. The TRIM function can remove extra space characters in cells. So with dynamic arrays it can handle ranges.
Convert text time to real time in Excel
Three different ways
I recently downloaded an example file for an Excel challenge. The challenge had a lot of things to do but they were all based on a Timestamp column that had text instead of times.
Find the Closest Value in Excel
Dynamic array solution
On LinkedIn recently someone posted an Excel formula solution lamenting that it was long and complex. That of course was a challenge to me to simplify it.
Time differences in Excel
ABS to the rescue again
Here’s a technique to calculate the time differences when you aren’t sure which time is first or last. Note with standard Excel settings you cannot report negative time.
Back when text was just text
Text functions revisited
20 years ago my last article for the Accountants Weekly magazine was published. They spelled my name wrong after getting it right for all the other articles, maybe that’s why I stopped.