sthrncaliguy
Board Regular
- Joined
- Jul 28, 2009
- Messages
- 213
Hello,
I am struggling with a method to do a Vlookup via VBA, but to match a row with 2 criteria, instead of the typical 1 criteria.
My VBA function is going to do something like this..
For r = 2 to 25
For c = 6 to 10
ws.cells(r,c).value = ... Here is where I need help. I need the value to = Row X, Col 8 from another worksheet. I need to determine Row X based on 2 criteria, whats in Col 1 and Col 4 for example. The criteria values I am trying to match will be identified as offset cells from the source. So the first criteria I need to match will be offset(0,-4) from (r,c), and criteria 2 I want to match will be offset(1,c) from (r,c) in my Loop.
I hope this makes sense. Essentially I am saying I need to identify which row on Sheet 2 has the text string "John" in Column A, and "Friday" in Column E, and I want to return the value in Column G from that row. There will only be 1 row that matches both criteria, but there will be several matches for either criteria in their respective columns.
I am struggling with a method to do a Vlookup via VBA, but to match a row with 2 criteria, instead of the typical 1 criteria.
My VBA function is going to do something like this..
For r = 2 to 25
For c = 6 to 10
ws.cells(r,c).value = ... Here is where I need help. I need the value to = Row X, Col 8 from another worksheet. I need to determine Row X based on 2 criteria, whats in Col 1 and Col 4 for example. The criteria values I am trying to match will be identified as offset cells from the source. So the first criteria I need to match will be offset(0,-4) from (r,c), and criteria 2 I want to match will be offset(1,c) from (r,c) in my Loop.
I hope this makes sense. Essentially I am saying I need to identify which row on Sheet 2 has the text string "John" in Column A, and "Friday" in Column E, and I want to return the value in Column G from that row. There will only be 1 row that matches both criteria, but there will be several matches for either criteria in their respective columns.
Last edited: