Chapter 1

Using AI to Generate Formulas You Don't Understand

Chapter 1: Using AI to Generate Formulas You Don't Understand

This chapter is the core of the entire book. Every AI-assisted technique in subsequent chapters builds on this foundation. By the end of this chapter, you'll have the complete methodology for using AI with Excel formulas โ€” whether writing new ones, understanding existing ones, finding bugs, or making formulas cleaner and faster.

Why Use AI to Write Formulas

Three Real Pain Points

Before explaining the method, let's be honest about why most people struggle with Excel formulas. The root cause isn't lack of intelligence โ€” it's that formulas are designed for computers, not people.

Pain Point 1: Can't remember function names. Excel has over 500 functions. Even common ones number in the dozens. You know you want to "find a value from column A in column B's table" โ€” but you might not remember if that's VLOOKUP, MATCH, or INDEX. The function names are a memory barrier.

Pain Point 2: Argument order keeps tripping you up. Even if you know the function, you need to remember its argument order. VLOOKUP: lookup value, table range, column index, match type. Get one wrong and the whole result breaks โ€” and the error message won't tell you which argument failed.

Pain Point 3: Nested formulas are too complex to write or read. When you need "if A is greater than 100, return B, otherwise look up C in column D," you need to nest IF inside VLOOKUP or vice versa. The logic isn't hard โ€” translating it into nested formula syntax is where most people hit a wall.

The common root: Excel formula language is designed for the computer, not the human. AI can do the translation โ€” converting your human-language description of what you need into the formula syntax Excel understands.

The Right Way: The "Need Description Method"

Core Principle: Describe What You Want, Not the Formula

The most common mistake beginners make when using AI for formulas: they describe the formula, not the need.

Wrong: "Help me write a VLOOKUP formula to look up E2 in column A and return column B." If you already know you need VLOOKUP, you probably know how to use it.

Right: Describe what you're trying to accomplish in business terms โ€” let AI figure out the best function.

The WHAT-FROM-WHERE Framework

WHAT-FROM-WHERE Framework

WHAT
**What result do I want?** Describe what you want to appear in the target cell. Example: "I want to show the department name for a given employee," or "I want to sum all sales that meet two conditions."
FROM
**Where does the data come from?** Describe which sheet, which columns, what's in each column. Example: "Employee data is in Sheet1, columns A through C โ€” A is employee ID, B is name, C is department."


WHERE
**Where does the formula go?** Specify the target cell and what value is being used as the lookup key. Example: "Formula goes in D2, the employee ID to look up is in A2."

Using AI to Write Formulas: 4 Case Studies


1Case 1: Basic VLOOKUP Lookup You have a product price table (Sheet1: column A = product code, column B = unit price). Your sales sheet (Sheet2) has product codes in column A, and you need column B to automatically fill in the corresponding unit price.

Help me write a VLOOKUP formula
I have two worksheets:
Sheet1 (Price Table): Column A = product code, Column B = unit price, data starts at A2, about 100 rows
Sheet2 (Sales Table): Column A = product code, Column B = where I want to show the unit price

I need a formula in Sheet2's B2 cell that looks up the product code in A2 of Sheet2, finds it in Sheet1's Column A, and returns the corresponding unit price from Sheet1's Column B.

Please give me a formula I can paste directly into B2 and fill down. Excel version: Office 365.
=VLOOKUP(A2,Sheet1!$A:$B,2,0)

Explanation:
- A2: the product code in the current row (lookup value)
- Sheet1!$A:$B: search within Sheet1's A to B columns ($ locks the columns so they don't shift when filling down)
- 2: return the 2nd column of the lookup range, which is column B (unit price)
- 0: exact match; returns #N/A if not found

When you fill down, A2 becomes A3, A4, etc., while Sheet1!$A:$B stays fixed.


2Case 2: Multi-Condition SUMIFS Sales data table: column A = salesperson name, column B = product category, column C = sales amount. You need the total sales for "Zhang San" in the "Electronics" category.

I want to use SUMIF to calculate someone's sales in a specific category
My table structure:
Column A: Salesperson name (A2:A500)
Column B: Product category (B2:B500)
Column C: Sales amount (C2:C500)

I want a formula in another cell that sums the sales amounts where BOTH of these conditions are true:
Condition 1: Column A equals "Zhang San"
Condition 2: Column B equals "Electronics"

Please give me the formula and explain each argument.
=SUMIFS(C2:C500, A2:A500, "Zhang San", B2:B500, "Electronics")

Parameters:
- C2:C500: the range to sum (sales amounts)
- A2:A500, "Zhang San": first condition โ€” column A equals "Zhang San"
- B2:B500, "Electronics": second condition โ€” column B equals "Electronics"

If the name and category are in cells (e.g., E2 for name, F2 for category), use:
=SUMIFS(C2:C500, A2:A500, E2, B2:B500, F2)


3Case 3: Complex Nested IF Performance rating table: column A = employee name, column B = score. Rating rules: 90+ = "Excellent", 75-89 = "Good", 60-74 = "Satisfactory", below 60 = "Needs Improvement". You need column C to auto-fill the rating.

Help me write a nested IF formula to judge score levels
=IF(B2>=90,"Excellent",IF(B2>=75,"Good",IF(B2>=60,"Satisfactory","Needs Improvement")))

Nesting logic:
1. First checks if B2 >= 90. If yes, returns "Excellent". Otherwise continues.
2. Now we know B2 = 75. If yes, returns "Good". Otherwise continues.
3. Now we know B2 = 60. If yes, returns "Satisfactory".
4. If none of the above (B2 =75, B24Case 4: Text Extraction
  Column A contains entries in the format "City-Region-StoreCode", e.g., "Shanghai-Pudong-SH001". You need to extract city, region, and store code into separate columns B, C, and D.


Help me use formulas to extract text content







Since you're using Office 365, you can use the newer, cleaner functions:

B2 (City): =TEXTBEFORE(A2,"-") C2 (Region): =TEXTBEFORE(TEXTAFTER(A2,"-"),"-") D2 (Store Code): =TEXTAFTER(A2,"-",2)

For compatibility with Excel 2016/2019 (if colleagues use older versions):

B2 (City): =LEFT(A2,FIND("-",A2)-1) C2 (Region): =MID(A2,FIND("-",A2)+1,FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1) D2 (Store Code): =MID(A2,FIND("-",A2,FIND("-",A2)+1)+1,LEN(A2))



## Using AI to Explain Formulas You Don't Understand


Inheriting someone else's workbook with formulas you can't parse is an extremely common workplace scenario. Here's how to use AI to handle it.


### Basic Method: Paste the Formula, Ask for a Plain-English Explanation


  1Explain Case 1: Array Formula





---

---

  2Explain Case 2: Complex Nested Lookup





---

---

  3Explain Case 3: SUMPRODUCT with Date Logic





## Using AI to Debug Formula Errors


### The Three Things to Include When Reporting an Error


1. The formula itself
2. The error code (#REF!, #VALUE!, #N/A, etc.)
3. Your data structure (what's in each column)


  1Debug Case 1: #REF! Error





---

---

  2Debug Case 2: #N/A Error (Value Exists But Not Found)





---

  3Debug Case 3: #VALUE! Error in Date Formula





## Using AI to Optimize Your Formulas


### Optimization Type 1: Simplify Nesting


### Optimization Type 2: Cross-Version Compatibility


## Chapter Quick Reference: All Prompt Templates


| Scenario | Prompt Template | Key Elements |
| --- | --- | --- |
| **Write a new formula** | I want [WHAT]. Data is in [FROM: column descriptions]. Formula goes in [WHERE: target cell, lookup value source]. Excel version: [version]. | All three elements required |
| **Explain a formula** | Please explain step by step what each part of this formula does, in plain language: [paste formula]. Context: [column descriptions]. | Column context required for accurate explanation |
| **Debug an error** | Formula: [formula]. Error: [#XX! error]. Data structure: [column descriptions]. Situation: [specific details about what's happening]. | Error code + data structure |
| **Simplify a formula** | Please simplify this formula while keeping the same result: [formula]. Context: [column descriptions]. Excel version: [version]. | Version affects available functions |
| **Make compatible** | I used [new function], but need it to work in Excel [older version] for a colleague. Please give an equivalent: [formula]. | Specify target version |
| **Modify a formula** | I have this formula: [formula]. I need to change [specific change, e.g., "the lookup range from A:B to A:D and return the 3rd column"]. | Describe the specific change, not the full need |


**โœ… Tip**

> **Chapter Summary:**
>
>   The core of using AI for Excel formulas is the "Need Description Method" โ€” describe the result you want, not the formula you think you need.
>
>   Remember the WHAT-FROM-WHERE three elements: **what result / where is the data / where does the formula go.**
>
>   This method applies to every function and feature in every subsequent chapter. Next, Chapter 2 builds the Excel vocabulary you need to accurately describe your spreadsheet structure to AI.


  [
    Previous
    โ† Introduction: Why Excel Power Users Are All Using AI
  ](/books/ai-excel/introduction)
  [
    Next
    Chapter 2: Excel Basics โ†’
  ](/books/ai-excel/ch02-basics)
Rate this chapter
4.7  / 5  (100 ratings)

๐Ÿ’ฌ Comments