View Single Post
  #1   Report Post  
changeable
 
Posts: n/a
Default Multiple Vlookup?


Hi i have somedata that looks like this(sorry, i dont know how to
display my xlsheet here, so i choose to display it by graphic) :
[image: http://img.photobucket.com/albums/v5...able/data.jpg]
How can i assign an ID for each row to a columns next to the Column G
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/v5.../criteria.jpg]
For example: Row 3 matched the criteria of Row 10866 since E3 is bigger
than 3.121694 but smaller than 3.122874. Due to this reason, i need to
place and ID "26" at H3. Similary, if others row in my database(1st
picture) that matched some of the criteria , says, criteria 31(not
shown in pic 2 but it is designed in that format), a 31 should place in
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 (the
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 never
heard of VBA 10 days ago and dont have programming background). Hope
someone can tell me. Thanks.
[image: http://img.photobucket.com/albums/v5...eable/vba.jpg]

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

finally, pls forgive my bad english. Thanks


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

--
changeable
------------------------------------------------------------------------
changeable's Profile: http://www.excelforum.com/member.php...o&userid=15714
View this thread: http://www.excelforum.com/showthread...hreadid=276546