Hi all. I need help with some VBA using find and match type queries. I have a worksheet which has columns: ID, test depth and test result. I have a second worksheet which as ID, start depth, end depth and category. What I need the code to do is loop through each row in the first worksheet and check to find the ID in the second worksheet. Then see if the test result depth (the second col) for that row falls between the start depth and end depths (second and third cols in the other worksheet). If it matches the ID but the test depth isn’t between the two depths on that row, then it moves on to the next row. If it matches the ID and the test depth in between the values in col 2 and 3, then the code should return the category of that row (col 4) to col 3 of the first worksheet.
Sheet 1
<tbody>
</tbody>
Sheet 2
<tbody>
</tbody>
Hope that’s clear. Thanks in advance!
Sheet 1
ID | Test Depth | Test Result | VBA Response |
BH1 | 0.75 | 6 | Type A |
BH1 | 3.8 | 1 | Type B |
BH1 | 1.11 | 25 | Type A |
<tbody>
</tbody>
Sheet 2
ID | Start Depth | End Depth | Category |
BH1 | 0 | 1.45 | Type A |
BH1 | 1.45 | 4 | Type B |
BH1 | 4 | 5 | Type C |
<tbody>
</tbody>
Hope that’s clear. Thanks in advance!