mscallisto
Technical User
My VLookup produces no matches.
I have a table that looks like this:
And data that looks this
My VLookup produces no matches.
Yet If I change the value 71110 to abcde in both the lookup table and the data the VLookup works great.
I have tried everything to ensure the table and data are the same type but aparently I'm missing something somewhere.
btw I added Company to the watch window and it shows the (1) value to be "variant double" and the (2) value to be "variant string"
while SearchItem is "String"
so I'm certain the No Match is because of a "type" issue yet I can't see where.
I have a table that looks like this:
Code:
A B
-------------------------
71100 GS EAST MGMT
71140 GS EAST TECH SUPP
71102 GS EAST NTWK/HD
71103 GS EAST HELP DESK
71104 GS EAST WEB APPS
71105 GS EAST SAP DEV
71110 GS EAST ITASCA DT
71130 GS WEST MGMT
And data that looks this
Code:
A B
-------------------------
71140 - Content Management Delivery
71156 GS Info Deliver/Bus Sys -
71110 Advanced Tech -APP Software
Code:
Sub CleanUpData()
Dim intLastRow As Integer
Dim usedrowsCol_B As Integer
Dim SearchItem As String
Dim Company As Range
intLastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
usedrowsCol_B = Worksheets("sheet2").Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set Company = Worksheets("sheet2").Range("A1:B" & usedrowsCol_B)
For Ii = 1 To intLastRow
SearchItem = Mid(Trim(Cells(Ii, 2)), 1, 5)
x = Application.VLookup(SearchItem, Company, 2, False)
If IsError(x) Then
x = "no match found"
Else
MsgBox ("match found")
End If
etc.
My VLookup produces no matches.
Yet If I change the value 71110 to abcde in both the lookup table and the data the VLookup works great.
I have tried everything to ensure the table and data are the same type but aparently I'm missing something somewhere.
btw I added Company to the watch window and it shows the (1) value to be "variant double" and the (2) value to be "variant string"
while SearchItem is "String"
so I'm certain the No Match is because of a "type" issue yet I can't see where.