Parse Unstructured Text into Clean Excel Columns

This prompt generates specific Excel formulas to split messy text strings into organized columns while handling edge cases like missing delimiters.

Text prompt for ChatGPT and Claude

Prompt

Prompt
Act as an Excel data analyst. Your job is to provide robust formulas to split unstructured text into distinct columns. Before providing formulas, ask these 3 questions: 1. Paste 5 rows of your messy data. 2. What specific character or pattern separates the data (e.g., pipe, slash, space)? 3. Are there variable lengths or missing delimiters in some rows? Wait for my answers. Once I answer, provide: 1. A table showing the final structure. 2. The exact Excel or Google Sheets formulas for each column, using TEXTBEFORE, TEXTAFTER, and IFERROR to handle missing data. 3. A brief explanation of how to handle the edge cases found in my data. Do not use placeholders. This is not legal or accounting advice; consult a qualified professional for complex data integrity tasks.

Example output

Formulas that split raw text into columnsRaw Name|Phone|Email text becomes three clean columns
  1. Name (Column B)Column B=TEXTBEFORE(A2, "|")
  2. Phone (Column C)Column C=TEXTBEFORE(TEXTAFTER(A2, "|"), "|")
  3. Email (Column D)Column D=IFERROR(TEXTAFTER(A2, "|", 2), "N/A") returns N/A if missing

Example for: splitting customer contact logs formatted as Name|Phone|Email where some emails are missing.

Target Data Structure

| Column A (Raw) | Column B (Name) | Column C (Phone) | Column D (Email) |
|---|---|---|---|---|---|---|---|---|---|---|---|
| John Doe|555-0101|john@test.com | John Doe | 555-0101 | john@test.com |
| Jane Smith|555-0102| | Jane Smith | 555-0102 | N/A |

Formulas
  • Name (Column B): =TEXTBEFORE(A2, "|")
  • Phone (Column C): =TEXTBEFORE(TEXTAFTER(A2, "|"), "|")
  • Email (Column D): =IFERROR(TEXTAFTER(A2, "|", 2), "N/A")
Handling Edge Cases
  • Missing Delimiters: The formula for Column D uses IFERROR to return N/A if the second pipe is not found, preventing errors in rows with incomplete contact info.
  • Variable Lengths: By using TEXTAFTER with the instance number (the 2 in the third formula), we ensure the formula correctly identifies the email even if the name or phone number lengths vary significantly between rows.
  • Data Integrity: Always copy these formulas down the entire length of your dataset. If you have older versions of Excel that lack these functions, you may need to use a combination of LEFT, FIND, and LEN instead.
Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces structured input to ensure formulas are tailored to your specific delimiter pattern.
  • Uses IFERROR and instance-based text extraction to prevent common errors when data is missing.
  • Provides a clear mapping of raw input to clean output columns for immediate implementation.

Use this when you have messy text in a single cell that needs to be split into multiple clean columns. It works best in ChatGPT, Claude, or Gemini. Paste your raw data once the model asks for it.

Common edits

  • Change the delimiter in the formula if your data uses commas or semicolons instead of pipes.
  • Adjust the final fallback text from N/A to blank quotes if you prefer empty cells over text labels.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Excel & Spreadsheets

Clean phone numbers and postal codes using Excel formulas

Transform irregular contact details into uniform formats for clean CRM imports. Use this whenever raw exports mix dashes, dots, spaces, or leading zeroes.

Excel & Spreadsheets

Deduplicate spreadsheet rows keeping latest entry

Finds duplicate records in your data and generates clean formulas or step-by-step instructions to keep only the newest record.

Excel & SpreadsheetsGemini

Write Google Sheets REGEX Formulas to Extract and Clean Text

Get ready-to-paste REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH formulas for Google Sheets with a token-by-token breakdown.

Excel & Spreadsheets

Strip hidden characters and non-printing breaks in Excel

Remove hard carriage returns, non-breaking spaces, and invisible ASCII artifacts that break lookups. Use this after copying data from web forms or PDFs.

Excel & Spreadsheets

Fix divide-by-zero errors in Excel variance formulas

Eliminate #DIV/0! errors in budget variance calculations with clean, professional handling for zero or missing values.

Excel & Spreadsheets

Highlight matching values across two separate spreadsheet columns

Generate the exact conditional formatting formula and click-by-click instructions to mark duplicate values found across two columns.