In this example, the goal is to make a noun plural when the number of items is greater than one. In many cases, a noun can be made plural by adding an "s". However, many nouns have an irregular plural form, and the main challenge is to handle these exceptions.
In the example shown, the formula uses these ingredients:
- IF function – to check the number of items
- VLOOKUP function – to lookup irregular plural forms
- IFNA function – to take action when there is no irregular form
- Concatenation – to glue text together
Note: There are many ways to solve a problem like this in Excel, and this is just one approach.
Adding an "s"
In the simplest case, the only task is to add an "s" to the end of a word using concatenation. This can be done with a formula like this:
=C5&"s" // simple concatenation
The ampersand operator (&) is used to join an "s" to the word in column C.
However, we don't want to add an "s" unless the number in column B is greater than 1. For this, we can use the IF function to check the number in column B:
In this version of the formula, we only add an "s" when the number in B5 is greater than 1. At this point, the formula handles the base case without trouble, but it won't handle words with irregular plural forms.
Handling irregular forms
To handle words with an irregular plural form, we need to perform a lookup. In the example shown, we do this with the VLOOKUP function:
where wordtable is the named range F5:G11. Here, we use VLOOKUP to locate a word in a table and return the irregular plural from the second column. Obviously, this only works when the table contains an entry for a given word. If a word does not exist in the table, VLOOKUP will return a #N/A error, and we can use this error to take some other action. The trick is to nest VLOOKUP inside the IFNA function to trap the error like this:
where "other" represents a different action. The idea is that words with an irregular plural form need to have an entry in the table. At this point in the formula, we know the word should be plural. If we check the table and can't find the word, we can assume the word does not have an irregular plural form and we can simply add an "s".
Putting it all together
We now have all the pieces we need for a single formula:
- Make plural only when number > 1
- Handle a regular plural form
- Handle an irregular plural form
We now need to assemble these pieces together in a logical flow like this:
If number is greater than one, make the word plural, otherwise, return the original word. When making a word plural, check a custom table first to see if there is an irregular form. If there is an irregular form, use it. If an entry is not found, simply add an "s".
The formula that implements this logic looks like this:
The formula that appears in the example performs one additional step: it concatenates the number from column B to the result from the formula above so that the number appears together with the plural form of the noun:
This results in a text string like "3 apples" and it makes it easier to quickly check results.
Note: if a noun has an irregular form but is not listed in the custom table, this formula will incorrectly add an "s". Therefore, all words with an irregular plural form that you want to handle must exist in the custom table. This is a limitation of the formula.