How to Remove Text By Position in Excel

Learn multiple Excel methods to remove text by position with step-by-step examples and practical applications.

excelformulaspreadsheettutorial
10 min read • Last updated: 7/2/2025

How to Remove Text By Position in Excel

Why This Task Matters in Excel

In every industry, data rarely arrives in a perfectly structured format. Customer IDs often combine letters and numbers, product codes include season prefixes, and downloaded reports frequently contain unwanted leading or trailing markers. Being able to remove text by position—meaning you can chop off a certain number of characters starting at a known position—turns messy strings into usable data without manual editing.

Imagine an e-commerce analyst who receives monthly inventory lists with item codes like “SP23-TSHIRT-XL”. The first four characters “SP23” identify the season, but her reporting system only accepts the core SKU “TSHIRT-XL”. A single click-and-drag formula that removes the first four characters makes the difference between hours of manual trimming and a repeatable workflow.

Financial departments constantly reconcile bank exports containing check numbers padded with leading zeros such as “000012345”. Removing those zeros by position converts the values into pure numerics, enabling accurate lookup functions and calculations. Marketing teams strip tracking parameters from URLs; healthcare administrators anonymize patient IDs by masking middle characters; logistics planners shave trailing warehouse tags from shipment numbers. Across all of these use cases, Excel provides a flexible, code-free way to surgically remove text segments, ensuring data integrity while saving time.

Mastering text-removal techniques also builds foundational skills for broader Excel tasks: text parsing, error trapping, dynamic buffer creation for dashboards, and Power Query transformations. Failing to understand positional removal often leads to hidden errors—reports include outdated prefixes, lookup mismatches occur because keys don’t align, and charts miscategorize items. In short, knowing how to remove text by position is a core competency that feeds directly into data cleaning, analysis, and automation in every modern workflow.

Best Excel Approach

The most direct approach for removing text at a known position is the REPLACE function. REPLACE lets you specify:

  1. The original text,
  2. The starting position where removal begins,
  3. The number of characters to delete,
  4. (Optionally) the new text to insert—simply leave this argument empty ("") to delete.

Because REPLACE performs everything in one step without helper formulas, it is fast, transparent, and works in every supported version of Excel (back to Excel 2003). Use REPLACE when you know:

  • Exactly how many characters you want gone,
  • Exactly where removal starts (fixed position or computed with FIND/SEARCH).

If either the start position or length is dynamic—say, determined by a hyphen that moves—you can nest FIND inside REPLACE to locate it automatically.

Syntax recap:

=REPLACE(old_text, start_num, num_chars, new_text)

Where:

  • old_text – the original string (cell reference or literal).
  • start_num – position of the first character to remove.
  • num_chars – how many characters to remove.
  • new_text – what to insert in their place ("" to delete).

Alternatives exist for special circumstances:

=LEFT(text, len_to_keep) & RIGHT(text, chars_from_end)
=TEXTAFTER(text, delimiter, [instance_num])
```excel
\`=TEXTBEFORE(\`text, delimiter, [instance_num])

Flash Fill, Power Query, and VBA offer GUI or code-based solutions when formulas are impractical or performance critical.

Parameters and Inputs

Before writing any formula, confirm four key inputs:

  1. old_text (required) – Accepts text or numbers stored as text. For numbers formatted as General, wrap with TEXT or include apostrophes.
  2. start_num (required) – Integer ≥ 1. Non-integers are truncated; values less than 1 return #VALUE!.
  3. num_chars (required) – Integer ≥ 0. Zero returns the original string unchanged. Using LEN(text)-n dynamically removes “n” trailing characters.
  4. new_text (optional) – Typically "" for deletion but can contain any replacement text.

Data prep tips:
• Clean non-printing characters first with TRIM or CLEAN to avoid off-by-one positions.
• Ensure consistent text length if using fixed positions.
• Validate dynamic positions using FIND and wrap with IFERROR to catch missing delimiters.
• When removing characters to convert IDs to numbers, wrap the final result in VALUE to coerce numeric data types.

Edge cases: empty cells, text shorter than expected, multi-byte Unicode characters, and mixed directionality strings (rare) all demand extra validation to avoid #VALUE! errors or unexpected truncation.

Step-by-Step Examples

Example 1: Basic Scenario – Remove Leading Season Codes

Suppose cells [A2:A6] contain:

A
SP23-TSHIRT-XL
SP23-JEANS-32
SP23-CAP-RED
SP23-HOODIE-M
SP23-SOCKS-6

Goal: strip the first four characters (“SP23”) plus the hyphen, making SKU codes clean.

  1. In B2 enter:
\`=REPLACE(\`A2,1,5,\\"\\")

Explanation: start at position 1, remove 5 characters, insert nothing.
2. Fill downward. Result:

B
TSHIRT-XL
JEANS-32
CAP-RED
HOODIE-M
SOCKS-6

Why it works: fixed season code length means start and length are constants. Any variation in the remaining string length does not affect removal.

Variations: If a new season arrives with “FA23”, same length, formula still works. Troubleshoot by checking LEN for anomalies; if length differs, consider using FIND to locate the first hyphen dynamically:

\`=REPLACE(\`A2,1,FIND(\\"-\\",A2),\\"\\")

Example 2: Real-World Application – Mask Middle Digits of Credit Card Numbers

Compliance requirements often demand that only the first 4 and last 4 digits of a credit card number remain visible. Given [B2:B5]:

B
4310548876543209
5500123412341234
340000199912345
6011009876543210

Goal: replace positions 5-12 with eight asterisks.

  1. Calculate how many digits to mask: Always 8.
  2. Formula in C2:
\`=REPLACE(\`B2,5,8,\\"********\\")

Result:

C
4310********3209
5500********1234
3400********2345
6011********3210

Business value: instantly anonymizes sensitive data before sharing.

Integration: Combine with CONCAT to add spaces every 4 digits, or load results into Power Query for secure export.

Performance notes: REPLACE operates in linear time; even 100k rows render quickly. For larger datasets, store formulas in an adjacent column, convert to values, then remove formulas to shrink workbook size.

Example 3: Advanced Technique – Remove Variable Trailing Tags from URLs

Marketing export file in column D contains:

We need everything before “?utm”.

Step breakdown:

  1. Find position of “?utm”:
\`=FIND(\`\\"?utm\\", D2)
  1. Compute length to keep:
\`=FIND(\`\\"?utm\\", D2)-1
  1. Combine with LEFT or use REPLACE:
\`=REPLACE(\`D2, FIND(\\"?utm\\", D2), LEN(D2), \\"\\")

or more elegantly in Excel 365:

\`=TEXTBEFORE(\`D2,\\"?utm\\")

Advanced considerations:
• “?utm” may be uppercase or mixed case; wrap FIND within LOWER to normalize.
• Some URLs might lack “?utm”; wrap full logic in IFERROR to return original URL.
• If multiple query parameters exist, identify second “?” or use TEXTAFTER/TEXTSPLIT arrays to parse entire strings into columns.

Performance tip: When processing hundreds of thousands of URLs, switch to Power Query and its Text.BeforeDelimiter function; M-code is multi-threaded and avoids recalculation overhead in the grid.

Tips and Best Practices

  1. Document Your Parameters: Add a comment or use structured references so teammates know why start_num equals 5.
  2. Dynamic Lengths over Hard-Coding: Prefer LEN(text)-n for trailing removals to keep formulas resilient to size changes.
  3. Combine with FIND for Flexibility: When delimiters move, FIND stabilizes the start position.
  4. Convert to Values After Cleaning: Prevent accidental overwriting and reduce file size by pasting as values once checked.
  5. Nest in IFERROR Early: Gracefully handle unexpected strings, preventing #VALUE! from propagating through dashboards.
  6. Test with LEN: After removal, confirm output length to catch off-by-one errors.

Common Mistakes to Avoid

  1. Off-by-One Start Positions: Users often forget that Excel’s character index starts at 1, not 0. Double-check using MID(text, start,1) to preview the character you plan to remove.
  2. Forgetting to Use Double Quotes for Empty Replacement: Omitting new_text argument or mistyping "" causes #N/A. Always supply an explicit empty string.
  3. Deleting Too Many Characters: Hard-coding num_chars without testing different data lengths removes extra characters, breaking keys. Check LEN on samples.
  4. Ignoring Case Sensitivity in FIND: FIND is case-sensitive; missing delimiters cause errors. Use SEARCH if mixed casing is expected.
  5. Leaving Formulas in Production Files: Positional deletion often precedes imports to other systems. Convert formulas to values to avoid recalculation surprises when files are reopened.

Alternative Methods

MethodVersion SupportStrengthsWeaknesses
REPLACEAllSimple, single formula, fastRequires known start and length
LEFT & RIGHT concatenationAllGood for fixed leading and trailing partsClunky if middle removal varies
TEXTBEFORE / TEXTAFTERMicrosoft 365Intuitive delimiter-based removal, spill-awareNot in older versions
Power QueryExcel 2010+ (with add-in)Handles millions of rows, no formula load, GUI-drivenExtra step, refresh required
Flash FillExcel 2013+No formulas, AI pattern recognitionNot dynamic; must re-flash on data change
VBA ReplaceAllFull control, loops, UI automationMacro security settings, maintenance overhead

Choose REPLACE for everyday grid work, TEXT functions for delimiter-driven strings in 365, and Power Query when data volumes or refresh schedules demand robustness.

FAQ

When should I use this approach?

Use positional removal whenever the characters you want to delete occupy consistent positions, such as known prefixes, suffixes, or masked segments. It is ideal for cleaning codes, truncating IDs, and preparing data for lookup operations.

Can this work across multiple sheets?

Absolutely. Reference cells on other sheets by prefixing the sheet name:

\`=REPLACE(\`\\'Raw Data\\'!A2,1,3,\\"\\")

Fill the formula on your destination sheet; the logic remains intact as long as source sheet names stay unchanged.

What are the limitations?

REPLACE cannot process entire ranges at once; each cell requires its own formula instance. It also relies on static character counts, so varying pattern lengths need nested FIND/SEARCH or delimiter-oriented functions. Finally, excessively long formulas may become hard to audit.

How do I handle errors?

Wrap the entire REPLACE (or composite) formula inside IFERROR:

\`=IFERROR(`
   REPLACE(A2, FIND(\\"-\\",A2), 1, \\"\\"),
   \\"Delimiter not found\\"
\)

This prevents #VALUE! from cascading. Always test for blank cells and unexpected string lengths.

Does this work in older Excel versions?

REPLACE is available back to Excel 2003. The delimiter-driven TEXTBEFORE/TEXTAFTER functions require Microsoft 365. If you are on Excel 2010 or 2013 without 365, stick with REPLACE, LEFT/RIGHT, FIND, and Power Query add-in.

What about performance with large datasets?

Formulas calculate swiftly for tens of thousands of rows. Beyond approximately 200k rows, file size and recalculation time grow. Mitigate by:

  • Converting formulas to values after one-time cleaning,
  • Using Power Query’s ETL engine,
  • Disabling automatic calculation during bulk updates,
  • Splitting workbooks if they exceed memory limits.

Conclusion

Removing text by position is a deceptively simple skill that unlocks powerful data-shaping capabilities. Whether you clean product codes, anonymize sensitive information, or strip tracking parameters, mastering REPLACE and its supporting functions provides a reusable toolkit for any text cleaning challenge. Add delimiter-based functions and Power Query to handle advanced scenarios, and you can tackle datasets of any size with confidence. Practice on your own data today, integrate error handling, and soon positional text removal will become a seamless part of your Excel repertoire.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.