• Home
• # Excel formula to remove the last forward slash

#### Chris

Staff member
Hello there! If you're looking to create an Excel formula that removes the last forward slash (/) from a URL in a cell, I've got just the thing for you. Using the following formula, you can achieve this easily:

=LEFT(A1,LEN(A1)-(RIGHT(A1)="/"))

Now, let me break it down for you:
1. LEFT(A1, LEN(A1) - (RIGHT(A1) = "/")): The LEFT function here returns the specified number of characters from the left side of the text in cell A1.
2. LEN(A1): The LEN function calculates the length (number of characters) of the text in cell A1.
3. RIGHT(A1) = "/": The RIGHT function returns the specified number of characters from the right side of the text. In this case, it checks whether the last character of the text in cell A1 is a forward slash (/).
4. (RIGHT(A1) = "/"): This part of the formula returns a boolean value (TRUE or FALSE) depending on whether the last character in A1 is a forward slash (/).
5. LEN(A1) - (RIGHT(A1) = "/"): This expression calculates the difference between the length of the text in cell A1 and the boolean value of the previous step. If the last character is a forward slash, the boolean value TRUE is treated as 1, and the result will be one less than the length of the text. If it's not a forward slash, the boolean value FALSE is treated as 0, and the result will be equal to the length of the text.
6. LEFT(A1, LEN(A1) - (RIGHT(A1) = "/")): Finally, the LEFT function uses the result of the previous calculation as the number of characters to return from the left side of the text in cell A1. If the last character is a forward slash, it will be removed; otherwise, the full text will be returned unchanged.
So, using this formula, you'll be able to neatly remove the last forward slash (/) in the text of the specified cell, if it's present. If there isn't a forward slash, the original text will be returned just as it is. Happy spreadsheet-ing!