# How to find the position of the last occurrence of a character in Excel

Count the characters, then mark the last one: =FIND(CHAR(1),SUBSTITUTE(A2,"/",CHAR(1),LEN(A2)-LEN(SUBSTITUTE(A2,"/","")))).

**Excel:** `=FIND(CHAR(1),SUBSTITUTE(A2,"/",CHAR(1),LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))))` (Excel 2024 and Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| URL | Last slash at |
| https://northwind.example/shop/chairs/oak-4471 |  |
| https://contoso.example/blog/2026/launch |  |
| https://fabrikam.example/about |  |
| https://litware.example/docs/api/v2/auth |  |
| https://adatum.example/ |  |

Formula in B2, filled to B6: `=FIND(CHAR(1),SUBSTITUTE(A2,"/",CHAR(1),LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))))`

Result: 38; 34; 25; 36; 23

## How it works

`LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))` counts the slashes: the length drops by one for each slash removed. That count is the instance number of the last slash, so SUBSTITUTE replaces just that one with `CHAR(1)`, and FIND returns where it is.

## Other ways

- `=LEN(TEXTBEFORE(A2,"/",-1))+1`: Excel 365: instance -1 is the last slash, so the length of the text before it, plus one, is its position.

## Common mistakes

- Text with no slash gives an instance of 0, and SUBSTITUTE returns #VALUE!. Wrap the formula in `IFERROR(…,0)`.
- To search for a word rather than one character, divide the length difference by the word's length before using it as the instance.

## Questions

**How do I get the text after the last slash?**

Use the position with MID, `=MID(A2,B2+1,LEN(A2))`, or skip it: `=TEXTAFTER(A2,"/",-1)`.

**How do I find the last space in a name?**

Swap the character: `=FIND(CHAR(1),SUBSTITUTE(A2," ",CHAR(1),LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/find-position-of-last-occurrence
