Nine years ago, I learned a time-saving Excel technique and even wrote a blog post about it. Then I barely used it. A few weeks ago, it popped back into my head as a possible solution, and since then it has been incredibly useful.
The trick? Use AutoCorrect to turn short codes into reusable formula segments. Type a few characters, press Space, and Excel inserts the formula text for you.
I cannot remember where I first learned this, but I have seen Wyn Hopkins use it several times. His presentation at the Global Excel Summit brought it back to the front of my mind. Now I am wondering why I was not using it all along.
Why save formula segments as short codes?
I am a huge fan of the FILTER function. But when we use FILTER, certain patterns come up repeatedly, such as filtering based on a list or filtering based on a partial text string.
The difficulty is not always understanding what we want to achieve. Sometimes it is remembering which functions we need, how they fit together, and which argument goes where.
AutoCorrect gives us a simple way to store those small, reusable pieces of formula logic. Rather than rebuilding the same combination each time, we insert a template and replace its placeholders.
To make this practical, we will first build a formula that filters values based on a list. Then we will save the reusable part as a short code.
The example workbook is available through my free Insiders Programme. Look for file reference 0325 AutoCorrect Hack.
|
Build the example: filter values based on a list
The workbook contains two Excel tables:
- Data: A table with columns named
ItemandValue. - List: A table with a column also named
List, containing the items we want to include.
Our goal is to calculate a total in cell H5: include the values from the Data table only when their corresponding items appear in the List table.
1. Find each item in the list with XMATCH
Start with this formula in H5:
=XMATCH(Data[Item],List[List])
XMATCH looks up each item from the Data table in the list and returns its position. For example, Alpha returns 1 because it is first in the list. Bravo returns 3 because it is third.
Items that do not appear in the list return #N/A. At this stage, we have positions and errors, but FILTER needs an array of TRUE or FALSE values.
2. Convert the results into TRUE or FALSE
Wrap XMATCH in ISNUMBER:
=ISNUMBER(XMATCH(Data[Item],List[List]))
ISNUMBER returns TRUE for a numerical position and FALSE for an item that was not found. We now have the include condition we need.
3. Filter the values
Use that condition as the second argument of FILTER:
=FILTER(Data[Value],ISNUMBER(XMATCH(Data[Item],List[List])),0)
The arguments work together like this:
Data[Value]supplies the values to return.ISNUMBER(XMATCH(...))identifies which rows to include.0is the result to return if nothing matches.
The matching values spill into the cells below the formula. Microsoft’s FILTER function reference explains the array, include, and if_empty arguments in more detail.
4. Sum the filtered values
Finally, wrap everything in SUM:
=SUM(FILTER(Data[Value],ISNUMBER(XMATCH(Data[Item],List[List])),0))
We now have the total of all values whose items appear in our list.
That formula works, but the part we are interested in reusing is much smaller:
ISNUMBER(XMATCH(Data[Item],List[List]))
This combination is the membership test. It is also the bit we might struggle to remember next time.
Create an AutoCorrect short code for the formula segment
Instead of storing the entire formula, we will save the ISNUMBER and XMATCH combination with descriptive placeholders.
1. Prepare the reusable text
While editing the completed formula, select only the ISNUMBER and XMATCH segment and press Ctrl+C. Paste the copied text into an empty cell as text so you can edit it.
Replace the workbook-specific references with placeholders:
- Replace
Data[Item]withAllItems. - Replace
List[List]withListItems.
The resulting template is:
ISNUMBER(XMATCH(AllItems,ListItems))
Do not include a leading equals sign. We want to insert this inside another formula, not start a separate formula.
The placeholders also remind us of the argument order: all the items we want to test come first, followed by the list of items to match against.
Select the complete template text and press Ctrl+C again.
2. Add the AutoCorrect entry
In the desktop Excel interface shown here:
- Go to File > Options.
- Select Proofing.
- Click AutoCorrect Options.
- In the Replace box, enter
inList. - In the With box, paste
ISNUMBER(XMATCH(AllItems,ListItems)). - Click Add.
- Click OK, then OK again to return to the worksheet.
That is the setup complete. AutoCorrect now holds a small formula template, ready whenever we need it.
Use the short code inside a formula
Now we can rebuild the calculation without typing the ISNUMBER and XMATCH combination ourselves.
- In an empty output cell, start typing
=FILTER(. - Select
Data[Value]for the array argument, then type a comma. - Type
inListand press Space.
Use the same capitalization as the saved short code. Pressing Space triggers the replacement, inserting the formula segment with its placeholders:
=FILTER(Data[Value],ISNUMBER(XMATCH(AllItems,ListItems))
We no longer need to remember the nested functions or their argument order. We just need to supply the references:
- Select
AllItemsin the formula and replace it by selecting the Data table’s Item column. - Select
ListItemsand replace it by selecting the List table’s List column.
Add ,0) to finish FILTER:
=FILTER(Data[Value],ISNUMBER(XMATCH(Data[Item],List[List])),0)
Press Enter to return the matching values, then wrap the formula in SUM to calculate the total:
=SUM(FILTER(Data[Value],ISNUMBER(XMATCH(Data[Item],List[List])),0))
The result is exactly the same as before. The difference is how little of the formula we had to remember and type.
Why not use a LAMBDA custom function?
You might be thinking that this logic would make a useful LAMBDA custom function. You would be right. In fact, I already have one for this purpose.
How often do I use it? Almost never.
For this particular task, adding the custom function to Name Manager and then using it feels like more hassle than I want. AutoCorrect is quick and easy: type the short code, press Space, and replace the placeholders.
The distinction is that AutoCorrect inserts formula text; it does not create a custom function. Once the placeholders are replaced, the cell contains the ordinary Excel formula.
The useful part is not the filtering formula
Filtering based on a list is just the example. The real time-saver is taking a small formula segment you use repeatedly, giving it clear placeholders, and saving it in AutoCorrect.
You do not have to memorize every useful function combination. Sometimes a few characters and a press of the Space key are all you need.


