Hey all,
I try to extract all the content after the character V in cell G and place it in cell m as part of procedure:
Sub findDefendant()
Dim RENums As Object
Dim LValue As String
Set RENums = CreateObject("VBScript.RegExp")
RENums.Pattern = "DEFENDANT"
Dim lngLastRow As Long
lngLastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
Dim i
For i = 1 To lngLastRow
If RENums.Test(Range("J" & i).Value) Then
pos = InStr("V", Range("G" & i))
LValue = Range("K" & i)
If pos <> 0 Then 'if V found continue
LValue2 = Right(Range("G" & i), Len(Range("G" & i)) - pos)
End If
Range("N" & i).Value = LValue
Range("O" & i).Value = LValue2
End If
Next i
End Sub
It does not put the values right of "V" from G into cell O. In fact, even though cell G does contain "V" in it, it leaves cell O completely blank for all instances.
Bookmarks