waveyurgi1
New Member
- Joined
- Sep 26, 2011
- Messages
- 3
Hello,
I am trying to do index match function with criteria ranges in another worksheets. The code kept on giving me " #Value!"..
Here is the code:
Sub test1()
Dim myvalue As Variant
Dim wsname As String
Dim i As Integer
Dim j As Integer
Dim r1 As range
Dim r2 As range
Dim r3 As range
Dim r4 As range
wsname = "CustomerIDbyParts"
i = 5
j = 6
Set r1 = ActiveWorkbook.Worksheets(wsname).range("D2:D4")
Set r2 = ActiveWorkbook.Worksheets(wsname).range("A2:A4")
Set r3 = ActiveWorkbook.Worksheets(wsname).range("B2:B4")
Set r4 = ActiveWorkbook.Worksheets(wsname).range("C2:C4")
myvalue = Evaluate("INDEX(r1, MATCH(ActiveSheet.Cells(5,1) & ActiveSheet(5,2) & ActiveSheet(1,4) ,r2 & r3 & r4, 0))")
ActiveSheet.Cells(i, j) = myvalue
End
The resulting cell of F5 kept on returning #Value!.. I suspect that my syntax for looking up the ranges from another worksheet is wrong?
I am wondering if anyone can help? Thank you.
I am trying to do index match function with criteria ranges in another worksheets. The code kept on giving me " #Value!"..
Here is the code:
Sub test1()
Dim myvalue As Variant
Dim wsname As String
Dim i As Integer
Dim j As Integer
Dim r1 As range
Dim r2 As range
Dim r3 As range
Dim r4 As range
wsname = "CustomerIDbyParts"
i = 5
j = 6
Set r1 = ActiveWorkbook.Worksheets(wsname).range("D2:D4")
Set r2 = ActiveWorkbook.Worksheets(wsname).range("A2:A4")
Set r3 = ActiveWorkbook.Worksheets(wsname).range("B2:B4")
Set r4 = ActiveWorkbook.Worksheets(wsname).range("C2:C4")
myvalue = Evaluate("INDEX(r1, MATCH(ActiveSheet.Cells(5,1) & ActiveSheet(5,2) & ActiveSheet(1,4) ,r2 & r3 & r4, 0))")
ActiveSheet.Cells(i, j) = myvalue
End
The resulting cell of F5 kept on returning #Value!.. I suspect that my syntax for looking up the ranges from another worksheet is wrong?
I am wondering if anyone can help? Thank you.