Sorry, now it should be OK
Sub SplitString()
Dim cl As Range
Dim vSplitString As Variant
Dim strName As String
Dim rngEMails As Range
With Worksheets("Email ID Data")
Set rngEMails = .Range("A1").Resize(.Range("A" & _
Rows.Count).End(xlUp).Row, 2)
End With
With Worksheets("Mail_Data")
For Each cl In .Range("F2:F" & .Range("F" & Rows.Count).End(xlUp).Row)
vSplitString = VBA.Split(cl.Value, "\")
strName = vSplitString(UBound(vSplitString))
.Range("A" & cl.Row).Value = Mid(strName, InStrRev(strName, "_") + 1, InStrRev(strName, ".") - InStrRev(strName, "_") - 1) 'Name
.Range("E" & cl.Row).Value = Left(strName, InStrRev(strName, "_") - 1) 'Subject
.Range("B" & cl.Row).FormulaR1C1 = "=VLOOKUP(RC1," & _
rngEMails.Address(True, True, xlR1C1, True) & ",2,False)"
Next cl
.Calculate 'Just in case if calculation is set to manual
With .Range("B2:B" & .Range("B" & Rows.Count).End(xlUp).Row)
.Value = .Value 'Convert to values
End With
End With
End Sub
Bookmarks