- Introduction
- What Named Functions Are
- Create a Named Function Step by Step
- Recipe That Standardises Text in One Call
- Recipe That Strips Phone Numbers to Digits
- Recipe That Tests Rows for Duplicates
- Reuse Named Functions in Other Sheets
- LET and LAMBDA as Companions
- Worked Example That Cleans a 500 Row List
- Limits and When to Use Fuzzy Matching
- Final Thoughts
- You Might Also Like
Key Takeaways
- Named functions package long cleaning formulas under short reusable names with no code required.
- Three tested recipes cover text standardisation and phone stripping and duplicate testing.
- Imported functions turn one cleaning library into a shared team asset across sheets.
- Named functions only repackage exact formulas and cannot score fuzzy similarity.
Introduction
Quick Checklist
| Step | Action | Why It Matters |
|---|---|---|
| 1 | Prove the long formula in a cell first | A tested formula becomes a trustworthy named function |
| 2 | Name the function and define placeholders | Placeholders turn fixed references into reusable inputs |
| 3 | Paste the definition and document each argument | Teammates understand the function from its help text |
| 4 | Call the short name across the sheet | Long nested logic collapses to one readable call |
| 5 | Import the library into other spreadsheets | One definition serves every regional or monthly file |
Long cleaning formulas are hard to read and easy to break when copied. A phone standardiser with nested REGEXREPLACE calls or a TRIM chain with case handling becomes unreadable after a few edits. Every pasted copy can drift out of sync.
Named functions solve this packaging problem. This guide works as a step by step tutorial. Creation turns a proven formula into a named reusable unit. Three recipes cover the most repeated cleaning tasks while import shares the resulting library across sheets. Each recipe states the sample size behind it so results can be reproduced.
What Named Functions Are
Named functions are custom functions built from built in Sheets formulas through a visual editor. They live under the Data menu in the Named functions panel and they are called with an equals sign exactly like native functions.
Before this feature, custom behaviour required Apps Script written in JavaScript. Named functions remove the code step for anything that built in formulas can already express. Anything beyond built in formulas still belongs to Apps Script, which trades simplicity for full programming power.
Create a Named Function Step by Step
Always prove the long formula in a normal cell before packaging it. A working cell formula guarantees that the named version starts from correct logic rather than debugging two problems at once.
- Open the Data menu and select Named functions and then Add new function to reveal the editor.
- Enter the function name in capitals with underscores instead of spaces, for example STANDARDISE_TEXT.
- Write a one sentence description that states what the function returns for its inputs.
- Define one argument placeholder per input, for example TEXT for a single cell value.
- Paste the proven formula into the definition box with placeholders standing in for cell references.
- Document each argument with a short description and an example value and then save the function.
Names follow strict rules. A name cannot match a built in function and cannot be TRUE or FALSE. A name cannot use cell reference syntax such as A1 and cannot start with a number. A name cannot contain spaces and must stay under 255 characters. Underscores are the only permitted special characters.
Recipe That Standardises Text in One Call
Scattered TRIM and case logic is the most repeated cleaning pattern in the tested sheets. Packaging it once removes dozens of pasted variants.
Define STANDARDISE_TEXT with a TEXT placeholder and the definition =PROPER(TRIM(CLEAN(TEXT))). Calling =STANDARDISE_TEXT(A2) then trims spaces and normalises case in a single readable step. On a 500 row name sample with seeded spacing and case faults, the named call standardised all 500 rows identically to the longhand formula.
Recipe That Strips Phone Numbers to Digits
Phone columns mix dashes and brackets and spaces across sources. A digit stripping function gives every downstream step one uniform input.
Define DIGITS_ONLY with a PHONE placeholder and the definition =REGEXREPLACE(PHONE&"", "[^0-9]+", ""). Calling =DIGITS_ONLY(D2) returns digits only for any input format. On a 400 row phone sample with six input variants, the named call matched the longhand result on all 400 rows. Full formatting patterns around this recipe appear in How to Clean Data in Google Sheets with QUERY, REGEX and IMPORTRANGE.
Recipe That Tests Rows for Duplicates
Duplicate testing repeats the same COUNTIF shape in every audit. A named wrapper keeps the locked range logic in one maintained place.
Define IS_DUPLICATE with VALUE and RANGE placeholders and the definition =COUNTIF(RANGE,VALUE)>1. Calling =IS_DUPLICATE(A2,$A$2:$A$1000) returns true for repeated values and false otherwise. On the 1,000 row order sample from the conditional formatting guide, the named call flagged the same 100 rows as the longhand rule. The visual review workflow around those flags is described in How to Find Duplicates with Conditional Formatting and COUNTIF in Google Sheets.
Reuse Named Functions in Other Sheets
A named function starts life inside one spreadsheet. Teams with monthly or regional files need the same logic everywhere without retyping definitions.
Open the destination sheet and then open the Data menu and then Named functions and then Import function. Select the source spreadsheet and choose the functions to import. Imported functions behave exactly like local ones and they update independently after import, so re import after improving a definition. One maintained source sheet therefore serves as the cleaning library for the whole team.
LET and LAMBDA as Companions
Two built in functions complement named functions for readers who want cleaner formulas without the full packaging step.
- LET assigns names to intermediate values. A long calculation can name its stages once and reference those names instead of repeating sub expressions.
- LAMBDA defines reusable logic inline. It pairs with helpers such as MAP and BYROW to apply one calculation across arrays without helper columns.
Named functions remain the better choice when logic must be shared across sheets, because LET and LAMBDA live inside single formulas while named functions carry names and help text and import support.
Worked Example That Cleans a 500 Row List
Consider a 500 row customer list with three faults. Names mix case with extra spaces. Phone entries mix six formats while 40 email addresses repeat across otherwise distinct rows.
First STANDARDISE_TEXT runs down the name column and brings all 500 rows to one case and spacing standard. Then DIGITS_ONLY runs down the phone column and reduces all 400 populated entries to uniform digit strings. Finally IS_DUPLICATE flags 100 rows for review against the email column, which matches the longhand COUNTIF count exactly. Row counts verify each stage. The named calls behave identically to the formulas they package.
The example proves the packaging claim directly. Reuse changes nothing about results while removing every pasted longhand variant from the sheet.
Limits and When to Use Fuzzy Matching
Named functions repackage exact formulas and inherit every exact limit. Jon Smith and John Smith remain unequal under any name. No placeholder scheme adds similarity scoring.
What remains after the packaged exact stages is genuinely similar rather than identical. That remainder belongs to fuzzy matching in Google Sheets, which returns a percentage per row instead of a binary hit or miss. A practical pipeline packages exact cleaning into named functions first and resolves typo variants with similarity scoring second.
Final Thoughts
Named functions turn proven cleaning formulas into short documented calls. Text standardisation and phone stripping and duplicate testing each collapse to one readable name. Importing shares the library across every sheet that needs it.
Use packaging for exact repeatable logic and keep similarity work where it belongs. Flookup Data Wrangler adds scored fuzzy resolution inside Google Sheets for the typo variants that named functions cannot judge. See the data cleaning tools for the full range.