HOW TO REMOVE CHARACTERS FROM STRING IN VBA?
WHAT IS A STRING IN VBA
REMOVING ANY SPECIFIC CHARACTER/S FROM STRING IN VBA
PLANNING THE SOLUTION
Whenever we need to inspect any string, we need to go character wise. As we need to eliminate c, we need to check every character sequentially.
- Get the input from the cell to a string.
- Examine the string one by one.
- If the character is c , skip it, if others, leave them as such.
- Return back the string.
‘ REMOVING CHARACTER C FROM THE GIVEN STRING
Dim temp1 As String
Dim temp2 As String
temp2 = “”
temp1 = Range(“F3”).Value ‘getting value from cell
Dim I As Integer
For I = 1 To Len(temp1)
If Not UCase(Mid(temp1, I, 1)) = “C” Then ‘scanning character if its equal to c or not
temp2 = temp2 + Mid(temp1, I, 1)
Range(“H3”).Value = “The given string after removing c is ” + temp2 ‘Sending the text back to cell.
RUNNING THE CODE AND OUTPUT
OTHER WAYS TO REACH THIS ARTICLE
WHAT IS EXCEL, HOW EXCEL WORKS, WRITE FORMULA IN EXCEL, EXAMPLE OF USING FORMULA IN EXCEL, ANIMATED EXAMLPE OF USING FORMULA IN EXCEL
YOU MAY LIKE
- HOW TO TROUBLESHOOT A FORMULA IN EXCEL?
- USE OF FONTS, FONT SIZE, INDENTATION, TEXT TO THE RIGHT, TEXT TO THE LEFT, TEXT IN THE MIDDLE ETC.
- how to insert table in excel?
- FOR MORE ARTICLES, CLICK EXCEL OR TYPE IN SEARCH BELOW.