Col A has 4,481 cells
Col B has 18,513 cells
How do I eliminate the cells in Col B whose 19 left-most characters do
NOT match the 19 left-most characters in any of the cells in Col A?
This can also be done, fairly easily, with a VBA Macro. Don't be put off -- detailed directions below.
Instead of eliminating the data in column B, I have chosen to write the results into a third column, for easier troubleshooting. This third column is completely cleared before the data is written, so when you test, be sure there is nothing you require in Column C, and also do this work on a copy of your data, not the original.
If the algorithm seems to work OK, it will be relatively simple to modify the code to delete the relevant cells in Col B, if that is what you want. Or you can just delete the entire column B.
To enter this Macro (Sub), <alt-F11> opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.
To use this Macro (Sub), <alt-F8> opens the macro dialog box. Select the macro by name, and <RUN>.
=======================================
Option Explicit
Sub DeDup()
Dim r1 As Range, r2 As Range, c As Range
Dim FirstRow As Long
Dim rDest As Range
Dim i As Long
Dim dataColl As Collection
'Set up ranges
FirstRow = 1 'or whichever row your data starts
Set r1 = Range(Cells(FirstRow, "A"), Cells(Cells.Rows.Count, "A").End(xlUp))
Set r2 = Range(Cells(FirstRow, "B"), Cells(Cells.Rows.Count, "B").End(xlUp))
Set rDest = r2.Offset(columnoffset:=1).Resize(rowsize:=1)
rDest.EntireColumn.ClearContents
Set dataColl = New Collection
'Generate unique list of contents of Col A
On Error Resume Next
For Each c In r1
dataColl.Add Item:=c.Value, Key:=Left(CStr(c.Value), 19)
Next c
On Error GoTo 0
i = 1
'if colB does NOT match, enter in Destination range
On Error GoTo ErrorHandler
For Each c In r2
dataColl.Add Item:=c.Value, Key:=Left(CStr(c.Value), 19)
rDest(i, 1).Value = c.Value
i = i + 1
dataColl.Remove (Left(CStr(c.Value), 19))
Skip: Next c
Exit Sub
ErrorHandler: Resume Skip
End Sub
====================================