I am trying to get some VBA to do the same thing as a match function w/multiple criteria so I can then make it more dynamic/functional across more than one cell.
In the cell I can get the following to work: (using Control+Shift+Enter)
Criteria1,Criteria2, and Criteria3 are cells with values(two strings, 1 number) in them.
Range1,Range2, and Range3 are named ranges in my workbook because I use them across multiple sheets.
I have also gotten this to work:
After looking at these threads:
http://www.mrexcel.com/forum/excel-...tiple-criteria-visual-basic-applications.html
http://www.mrexcel.com/forum/excel-...tiple-criteria-visual-basic-applications.html
I was able to get this to work in VBA: (Criteria1,Criteria2, and Criteria3 are now variables that are inputs to the VBA function)
but when I try to add in other criteria, I get a "#VALUE!" error.
I have tried the following (among a bunch of other combinations):
and
with the same error.
I feel like I am really close, just missing something simple. Any help? I am working in Excel 2010 if it makes a difference.
In the cell I can get the following to work: (using Control+Shift+Enter)
Criteria1,Criteria2, and Criteria3 are cells with values(two strings, 1 number) in them.
Range1,Range2, and Range3 are named ranges in my workbook because I use them across multiple sheets.
Code:
{=MATCH(Criteria1&Critera2&Criteria3,Range1&Range2&Range3,0)}
I have also gotten this to work:
Code:
{=MATCH(1,(Criteria1=Range1)*(Criteria2=Range2)*(Criteria3=Range3),0)}
After looking at these threads:
http://www.mrexcel.com/forum/excel-...tiple-criteria-visual-basic-applications.html
http://www.mrexcel.com/forum/excel-...tiple-criteria-visual-basic-applications.html
I was able to get this to work in VBA: (Criteria1,Criteria2, and Criteria3 are now variables that are inputs to the VBA function)
Code:
myResult = Application.WorksheetFunction.Match(Criteria1, Range("Range1"), 0)
but when I try to add in other criteria, I get a "#VALUE!" error.
I have tried the following (among a bunch of other combinations):
Code:
myResult = Application.WorksheetFunction.Match(Criteria1&Criteria2&Criteria3, Range("Range1")&Range("Range2")&Range("Range3"), 0)
and
Code:
myResult = Application.Evaluate("MATCH(Criteria1&Criteria2&Criteria3, Range1&Range2&Range3), 0)")
with the same error.
I feel like I am really close, just missing something simple. Any help? I am working in Excel 2010 if it makes a difference.