I only want to select characters found between parentheses "()" I found code that will select characters between the same string:
Public Function GetStuffYouWant(ByVal pInput As Variant, _
Optional pSplitChar As String = "-") As Variant
Dim varResult As Variant
Dim varPieces As Variant
If IsNull(pInput) Then
varResult = Null
Else
varPieces = Split(pInput, pSplitChar)
If UBound(varPieces) > 1 Then
varResult = varPieces(1)
Else
varResult = Null
End If
End If
GetStuffYouWant = varResult
End Function
It works great because when there is null values I do not get null error.
The trouble is I need to select characters between two known strings. I found this code that looks at two strings but I did not know how to write it into the first code to get my desired results:
dim first as integer
dim second as integer
dim result as string
first = instr(1,"yourtext","-")
second = instr(first+1,"yourtext","-")
if first > 0 and second > first then
second = second - first
result = mid("yourtext",first+1, second-1)
end if
This is an example of what I need:
Before: I need:
Issue Issue
------ ------
1 (Dog) at the carpet Dog at the carpet
2 <---Not a null error
3 (Cat) dog Cat