I need to search a range ("G3:Z") searching for the text "ECP". The text could be in any cell of the range per line item and would used in a sentence like structure.
The text could also be in varying formats e.g. ECP# 123456, ECP - 123456, ECP # 123456, ECP–123456, etc. (note the En dash is not a hyphen).
If found, I then need the parsed value to be entered into the same row from which the result was found, but entered into column "E" of the same row.
Below is what I was thinking (please excuse the incongruency; it's Friday or as I call it "Brain-Fried-day")
The text could also be in varying formats e.g. ECP# 123456, ECP - 123456, ECP # 123456, ECP–123456, etc. (note the En dash is not a hyphen).
If found, I then need the parsed value to be entered into the same row from which the result was found, but entered into column "E" of the same row.
Below is what I was thinking (please excuse the incongruency; it's Friday or as I call it "Brain-Fried-day")
Code:
Sub findECP()
Dim splitString As String
Dim splitStringLeft As String
Dim splitStringRight As String
Dim pos As Long
splitString = "111111-111*1"
pos = InStr(splitString, "*")
With Worksheets(10).Range("G3:Z")
Set c = .Find("ECP", LookIn:=xlValues)
If Not c Is Nothing Then ' check delimiter is found
firstAddress = c.Address
splitString = firstAddress.Value
pos = InStr(splitString, "ECP")
splitStringLeft = Left(splitString, pos - 1)
splitStringRight = Mid(splitString, , (pos + 10) - Right(pos, Find(" ")))
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub