Remove Last Two Characters From String Excel

5 min read

Introduction

If you need to remove last two characters from string excel in a spreadsheet, you are looking for a quick, reliable method that works across all versions of Microsoft Excel. This article will show you several built‑in functions, step‑by‑step instructions, and practical tips so you can accomplish the task efficiently, avoid common errors, and adapt the solution to various data scenarios.

Why Remove Last Two Characters?

Removing the final two characters from a text string is a frequent requirement in data cleaning, formatting, or extracting specific parts of identifiers. Typical situations include:

  • Trimming a product code that ends with a version number (e.g., “ABC1234” → “ABC12”).
  • Extracting a date stored as “20231130” and keeping only the year and month (“202311”).
  • Simplifying phone numbers that contain an extension (“5551234567x123” → “5551234567”).

Understanding the purpose helps you choose the most appropriate Excel function and avoid unnecessary complications Still holds up..

Built‑in Excel Functions

Using the LEFT and LEN Functions

The most straightforward approach combines the LEFT function with LEN.

  1. LEN returns the total number of characters in a cell.
  2. LEFT extracts a specified number of characters from the left side of a text string.

Formula:

=LEFT(A1, LEN(A1) - 2)
  • Replace A1 with the cell containing the original string.
  • The expression LEN(A1) - 2 calculates the length without the last two characters.

Why it works: If “HelloWorld” is in A1, LEN(A1) equals 10. Subtracting 2 gives 8, and LEFT returns the first 8 characters (“HelloWor”).

Using the REPLACE Function

The REPLACE function lets you replace a specific part of a text string based on position.

Syntax:

=REPLACE(text, start_num, num_chars_to_replace, new_text)

To drop the last two characters:

=REPLACE(A1, LEN(A1)-1, 2, "")
  • start_num is the position of the first character to replace, calculated as the total length minus 1.
  • num_chars_to_replace is 2 (the characters you want to delete).
  • new_text is an empty string, effectively removing those characters.

Using TEXTAFTER (Office 365 and Excel 2021)

The newer TEXTAFTER function extracts text after a specified delimiter. When combined with the tilde character (~), it can treat the whole string as a delimiter, allowing you to return everything before the last two characters Easy to understand, harder to ignore..

Formula:

=TEXTAFTER(A1, "~", -3)
  • The -3 argument tells Excel to return the text after the third occurrence from the right, which effectively leaves only the portion before the last two characters.

Step‑by‑Step Guide

Below is a concise, numbered list you can follow directly in your worksheet:

  1. Select the cell where you want the shortened result (e.g., B1).
  2. Enter the appropriate formula based on the function you prefer:
    • For LEFT/LEN: =LEFT(A1, LEN(A1)-2)
    • For REPLACE: =REPLACE(A1, LEN(A1)-1, 2, "")
    • For TEXTAFTER: =TEXTAFTER(A1, "~", -3)
  3. Press Enter. The cell will display the string without its final two characters.
  4. Copy the formula down the column by dragging the fill handle (small square at the bottom‑right corner) to apply it to other rows.
  5. Verify results by checking a few rows manually to ensure the correct characters were removed.

Common Use Cases

Product Codes

If your product codes follow a pattern like “XYZ‑12345”, you may want to keep only the prefix “XYZ‑123”. Using the LEFT/LEN formula automatically adjusts when the code length changes No workaround needed..

Date Stripping

When dates are stored as “YYYYMMDD” (e.g., 20231130), you might need “YYYYMM” for reporting. The same formula works: =LEFT(A1, LEN(A1)-2) yields “202311”.

Phone Number Extensions

For numbers with an extension (“5551234567x123”), you can first remove the “x” part with a SUBSTITUTE, then apply the removal of the last two characters:

=LEFT(SUBSTITUTE(A1,"x",""), LEN

(A1)-2))`

This nests two SUBSTITUTE calls so the "x" is stripped before the length is calculated and the final two characters are removed.

### Fixed-Width Identifiers

Many legacy systems export records with fixed-width fields. If a trailing two-character checksum or flag is appended to each record, the LEFT/LEN combination trims it cleanly regardless of the base length:

```excel
=LEFT(A1, LEN(A1)-2)

Tips for Reliable Results

  • Watch for empty or short cells. If a cell contains fewer than three characters, LEN(A1)-2 becomes zero or negative, and LEFT returns an empty string or an error. Wrap the formula in an IF check when your data is inconsistent:

    =IF(LEN(A1)>2, LEFT(A1, LEN(A1)-2), A1)
    
  • Account for hidden spaces. Trailing spaces inflate LEN, causing you to remove the wrong characters. Clean the input first:

    =LEFT(TRIM(A1), LEN(TRIM(A1))-2)
    
  • Preserve leading zeros. If the source is a number formatted with leading zeros, convert it to text with TEXT before trimming, or you may lose digits unexpectedly.

  • Prefer LEFT/LEN for compatibility. The REPLACE and LEFT/LEN approaches work in every version of Excel, while TEXTAFTER requires Office 365 or Excel 2021. Choose based on your environment.

Troubleshooting

If the result looks wrong, break the formula into pieces to inspect the intermediate values. That's why place =LEN(A1) in a helper cell to confirm the true length, then verify that LEN(A1)-2 points to the character you expect to keep. This step-by-step inspection quickly reveals whether the issue is an unexpected space, a hidden character, or a miscounted offset.

Conclusion

Removing the last two characters from a string is a routine but genuinely useful Excel operation, and the language gives you several reliable ways to do it. So the LEFT/LEN pairing is the most portable and readable choice, REPLACE offers precise positional control, and TEXTAFTER provides an elegant modern alternative for newer versions. Practically speaking, by matching the method to your Excel version and data conditions—and by guarding against short cells, stray spaces, and numeric formatting—you can trim text accurately at scale. Once the pattern clicks, you will find yourself reusing these formulas across product codes, dates, phone numbers, and fixed-width exports, turning a fiddly manual edit into a single, dependable formula.

Up Next

Just In

Others Went Here Next

In the Same Vein

Thank you for reading about Remove Last Two Characters From String Excel. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home