There are times we need to get the position of a certain character in a string.Below is a vba code which can be used to get a position of certain character.
Think there is a sentence or a word in a cell "C3".
So below code can be used to get the position of "@" in that sentence or word.
Dim cellValue As String Dim PosOfAt As Integer Dim WS1 As Worksheet Dim Rng As Range Set WS1 = Worksheets("Sheet1") Set Rng = WS1.Range("C3") cellValue = Rng.Value PosOfAt = InStr(1, cellValue, "@", vbTextCompare) 'Here PosOfAt equals to the position of "@" |