Multiple Vlookup?

C

changeable

Hi i have somedata that looks like this(sorry, i dont know how t
display my xlsheet here, so i choose to display it by graphic) :
[image: http://img.photobucket.com/albums/v509/changeable/data.jpg]
How can i assign an ID for each row to a columns next to the Column
if the column E and column F had match certain defined criteria?
This is how the criteria looks like:
[image
http://img.photobucket.com/albums/v509/changeable/criteria.jpg]
For example: Row 3 matched the criteria of Row 10866 since E3 is bigge
than 3.121694 but smaller than 3.122874. Due to this reason, i need t
place and ID "26" at H3. Similary, if others row in my database(1s
picture) that matched some of the criteria , says, criteria 31(no
shown in pic 2 but it is designed in that format), a 31 should place i
the H columns of the corresponding rows.

I have thought that this is a multiple criteria vlookup problem
However, i dont have the experience in using Vlookup function
Therefore, i try to achieve the same thing using this code (th
attached picture is what the code reference to):



code:
--------------------------------------------------------------------------------
Sub ID()
Dim i As Integer
Dim j As Integer
Dim coordinate As Variant
Dim criteria As Variant
Set coordinate = Range("E2:F131")
Set criteria = Range("J2:N128")
For i = 1 To 130
For j = 1 To 127
If coordinate(i, 1) = criteria(j, 2) And coordinate(i, 1)
criteria(j, 3) Then
Cells(i, 9).Value = criteria(j, 1)
ElseIf coordinate(i, 1) = criteria(j, 2) And coordinate(i, 2)
criteria(j, 5) Then
Cells(i, 9).Value = criteria(j, 1)
ElseIf coordinate(i, 1) = criteria(j, 3) And coordinate(i, 2)
criteria(j, 4) Then
Cells(i, 9).Value = criteria(j, 1)
ElseIf coordinate(i, 2) = criteria(j, 4) And coordinate(i, 2)
criteria(j, 5) Then
Cells(i, 9).Value = criteria(j, 1)
End If
Next j
Next i

End Sub
--------------------------------------------------------------------------------


However, i donno what's wrong with my code here too. (I have neve
heard of VBA 10 days ago and dont have programming background). Hop
someone can tell me. Thanks.
[image: http://img.photobucket.com/albums/v509/changeable/vba.jpg]

attached is my xlsheet. I dont know if this will help or not, but
choose to attached the xlsheet here.

finally, pls forgive my bad english. Thank

+-------------------------------------------------------------------
|Filename: testing.zip
|Download: http://www.excelforum.com/attachment.php?postid=2768
+-------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top