tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,926
- Office Version
- 365
- 2019
- Platform
- Windows
I am trying to replace the evaluate method with "only VBA".
This first piece of code is a "normal" index match, in that there is only a single criteria and so is entered simply by pressing the Enter key.
a and b return the same value, as expected.
c returns the correct value but d errors.
The error message is:
How can I change d to make it work?
Thanks
This first piece of code is a "normal" index match, in that there is only a single criteria and so is entered simply by pressing the Enter key.
a and b return the same value, as expected.
Rich (BB code):
Dim IndexRng As Range
Set IndexRng = Range("A1:A2")
Dim rng As Range
Set rng = Range("B1:B2")
Dim rng1 As Range
Set rng1 = Range("E3")
Dim a, b
a = Evaluate("=INDEX(" & IndexRng.Address & ",Match(" & rng1.Address & "," & rng.Address & ", 0), 1)")
b = Application.Index(IndexRng, Application.Match(rng1.Value, rng, 0), 1)
This second piece of code is an array formula because there are multiple criteria and is entered by pressing Ctrl+Shift+Enter.
c returns the correct value but d errors.
Rich (BB code):
Dim IndexRng As Range
Set IndexRng = Range("A1:A2")
Dim rng As Range
Set rng = Range("B1:B2")
Dim rng2 As Range
Set rng2 = Range("C1:C2")
Dim rng3 As Range
Set rng3 = Range("E3")
Dim rng4 As Range
Set rng4 = Range("F3")
Dim c, d
c = Evaluate("=INDEX(" & IndexRng.Address & ",Match(1, (" & rng3.Address & " = " & rng.Address & ") * (" & rng4.Address & "=" & rng2.Address & "),0))")
d = Application.Index(IndexRng, Application.Match(1, (rng3 = rng) * (rng4 = rng2), 0, 1))
The error message is:
Rich (BB code):
Run-time error '13':
Type mismatch
How can I change d to make it work?
Thanks
Last edited: