Option Explicit
'---------------------
Sub FindMyData()
'---------------------
Dim iRows As Long, iFldNum As Long, iResultOFF As Long
Dim vTxt
Dim sResultCol As String
Const kResultHdr = "Results"
Const kFOUND = "found"
Dim colVals As New Collection
Dim i As Integer
'load the legal search values
Sheets("find").Activate
Range("A1").Select
While ActiveCell.Value <> ""
colVals.Add ActiveCell.Value
ActiveCell.Offset(1, 0).Select 'next row
Wend
'add a result column
Sheets("data").Activate
Range("A1").Select
Selection.End(xlToRight).Select
If InStr(ActiveCell.Value, kResultHdr) = 0 Then
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = kResultHdr
End If
iFldNum = ActiveCell.Column
iResultOFF = iFldNum - Range("A1").Column
sResultCol = iFldNum & ":" & iFldNum
sResultCol = getMyColLtr()
'clear results col.
Columns(iFldNum).ClearContents
Range(sResultCol & "1").Value = kResultHdr
'get #rows
Range("A1").Select
iRows = ActiveSheet.UsedRange.Rows.Count
'MsgBox iRows
Range("A2").Select
While ActiveCell.Row <= iRows
vTxt = ActiveCell.Offset(0, 1).Value
For i = 1 To colVals.Count
If Val(Right(vTxt, 2)) = Val(colVals(i)) Then
ActiveCell.Offset(0, iResultOFF).Value = kFOUND
Exit For
End If
Next
ActiveCell.Offset(1, 0).Select 'next row
Wend
'filter results
ActiveSheet.Range("A1").AutoFilter Field:=iFldNum, Criteria1:=kFOUND
Set colVals = Nothing
'copy the results
SaveFoundData
End Sub
'---------------------
Public Function getMyColLtr()
'---------------------
Dim vRet
Dim i As Integer
vRet = Mid(ActiveCell.Address, 2)
i = InStr(vRet, "$")
If i > 0 Then vRet = Left(vRet, i - 1)
getMyColLtr = vRet
End Function
'---------------------
Sub SaveFoundData()
'---------------------
Range("A1").Select
ActiveSheet.UsedRange.Select
'Range("A1:G27").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\TEMP\found data.xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub