Remove first character from string
To remove the first character from a selected string you need to apply a combination of Excel RIGHT and LEN functions
Example: Remove first character from string
The formula uses the Excel RIGHT and LEN functions to remove the first character from the selected string. This formula links to cell C5 which captures the number of characters to remove, however, given this formula is only removing the first character from a string, this number will always be 1, therefore, you can enter this number (1) directly into the formula.
|
Sub Remove_first_character_from_string()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'apply the formula to remove the first character from a string
ws.Range("D5") = Right(ws.Range("B5"), Len(ws.Range("B5")) - ws.Range("C5"))
ws.Range("D5") = Right(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.
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: If using the same VBA code ensure that the string from which you want to remove the first character is captured in cell ("B5").
Number of Characters to Remove: Given this tutorial shows how to remove the first character from a string, the number of characters to remove will always be 1. Therefore, you can enter this value (1) directly into the VBA code, given it's a constant no matter which string the formula is applied against.
Worksheet Name: Have a worksheet named Analyst.
String: If using the same VBA code ensure that the string from which you want to remove the first character is captured in cell ("B5").
Number of Characters to Remove: Given this tutorial shows how to remove the first character from a string, the number of characters to remove will always be 1. Therefore, you can enter this value (1) directly into the VBA code, given it's a constant no matter which string the formula is applied against.
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
String: Select the string from which you want to remove the first character by changing the cell reference ("B5") to any cell in the worksheet that contains the string and doesn't conflict with the formula.
Output Range: Select the output range by changing the cell reference ("D5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
String: Select the string from which you want to remove the first character by changing the cell reference ("B5") to any cell in the worksheet that contains the string and doesn't conflict with the formula.
EXPLANATION
This tutorial explains and provides step by step instructions on how to remove the first character from a string using an Excel and VBA method. Both of the methods apply the RIGHT and LEN functions to achieve this.
This tutorial explains and provides step by step instructions on how to remove the first character from a string using an Excel and VBA method. Both of the methods apply the RIGHT and LEN functions to achieve this.
FORMULA
=RIGHT(string,LEN(string)-1)
=RIGHT(string,LEN(string)-1)
ARGUMENTS
string: The string from which you want to remove the first character.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Remove last character from string | How to remove the last character from a selected string using an Excel and VBA method | |
Remove characters from left | How to remove characters from the left of the selected string using an Excel and VBA method | |
Remove characters from right | How to remove characters from the left of the selected string using an Excel and VBA method | |
Remove specific characters from string | How to remove specific characters from a string using an Excel and VBA method |