Return text after a specific character
To return text after a specific character we can apply a combination of Excel MID and FIND functions
Example: Return text after a specific character
Dim ws As Worksheet
ws.Range("C5") = Mid(ws.Range("B5"), (Application.WorksheetFunction.Find("/", ws.Range("B5"), 1) + 1), 256)
End Sub
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.
Worksheet Name: Have a worksheet named Analysis.
Text: If using the exact VBA code the string from which you want to extract text needs to be captured in cell ("B5").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Text: Select the cell that captures the string from which you want to extract text by changing the cell reference ("B5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Character: In this example we are returning all of the text after the "/" sing. You can change this in the VBA code to any character that is captured in the cell that captures the string from which you want to extract the text.
METHOD 2. Return text after a specific character using VBA with a formula function
VBA
Dim ws As Worksheet
ws.Range("C5").Formula = "=MID(B5,(FIND("/",B5,1)+1),256)"
End Sub
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.
Worksheet Name: Have a worksheet named Analysis.
Text: If using the exact VBA code the string from which you want to extract text needs to be captured in cell ("B5").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("C5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Text: Select the cell that captures the string from which you want to extract text by changing the cell reference ("B5") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Character: In this example we are returning all of the text after the "/" sing. You can change this in the VBA code to any character that is captured in the cell that captures the string from which you want to extract the text.
To return text after a specific character we can apply a combination of Excel MID and FIND functions.
=MID(string,(FIND("/",string,1)+1),256)
ARGUMENTS
string: The string that captures the text that you want to extract.