Hi
I have a list of full names (one name per cell) to compare to in column A. In column E, I have a string of varying lengths containing first names and surnames separated with a semicolon - for example "firstname1 surname1; firstname2 surname2; firstname3 surname3"
Column F contains the last firstname surname in the string in column E. What I want to do is compare the names in Column F to my range A2:A40, and where there's not a match, to extract the last matching name from the string instead.
So;
Column A contains - "Harry Potter" "Hermione Granger" "Ron Weasley" (separate cells)
Column E contains - "Harry Potter; Ron Weasley; Draco Malfoy; Albus Dumbledore" (string in one cell)
Column F contains - "Albus Dumbledore"
Column G desired result = "Ron Weasley"
I have this that only gets me the first firstname surname from the string instead, where Column F doesn't match Column A
Any ideas please?
I have a list of full names (one name per cell) to compare to in column A. In column E, I have a string of varying lengths containing first names and surnames separated with a semicolon - for example "firstname1 surname1; firstname2 surname2; firstname3 surname3"
Column F contains the last firstname surname in the string in column E. What I want to do is compare the names in Column F to my range A2:A40, and where there's not a match, to extract the last matching name from the string instead.
So;
Column A contains - "Harry Potter" "Hermione Granger" "Ron Weasley" (separate cells)
Column E contains - "Harry Potter; Ron Weasley; Draco Malfoy; Albus Dumbledore" (string in one cell)
Column F contains - "Albus Dumbledore"
Column G desired result = "Ron Weasley"
I have this that only gets me the first firstname surname from the string instead, where Column F doesn't match Column A
VBA Code:
For Each c1 In Sheets("test").Range("F2:F" & lastRow2)
For Each c2 In Sheets("tableData").Range("A2:A40")
If c2.Value <> c1.Value Then
c1.Offset(, 1).Value = Split(c1.Offset(, -1).Value, ";")
End If
Next
Next
Any ideas please?
Last edited: