Remove characters from right

To remove characters from the right of the selected string you need to apply a combination of Excel LEFT and LEN functions

Example: Remove characters from right

Remove characters from right

METHOD 1. Remove characters from right

EXCEL

=LEFT(B5,LEN(B5)-C5)
The formula uses the Excel LEFT and LEN functions to remove the first four characters from the selected string.

METHOD 1. Remove characters from right using VBA

VBA

SubRemove_characters_from_right()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to remove four characters from the right
ws.Range("D5") = Left(ws.Range("B5"), Len(ws.Range("B5")) - ws.Range("C5"))

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analyst.
String: Ensure that the string from which you want to remove characters is captured in cell ("B5").
Number of Characters to Remove: Ensure that the number of characters that you want to remove from the selected string is captured in cell ("C5").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code to any cell in a worksheet, that doesn't conflict with the formula.
String: Select the string from which you want to remove characters by changing cell reference ("B5") to any cell in the worksheet, that contains the string and doesn't conflict with the formula.

Explanation about the formula used to remove characters from the right

EXPLANATION

EXPLANATION
To remove characters from the right of the selected string you need to apply a combination of Excel LEFT and LEN functions.
FORMULA
=LEFT(string,LEN(string)-num_char)

ARGUMENTS
string: The string from which you want to remove the selected number of characters.
num_char: The number of characters that you want to remove from the selected string.