converting excel function to VBA

alfordtp

Board Regular
Joined
Oct 3, 2008
Messages
62
anyone have an idea how to convert a match statement to vba with multiple conditions? I have situations from where it has to match two criteria, to matching six criteria.

Any thoughts on how to do this?


=IF(AND(ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$D$1),0)),
'ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$G$1),0))),1,"")

Thanks!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
To place the formula in AA2, for example, try...

Code:
[font=Courier New]Range("AA2").FormulaArray = "=IF(ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$D$1),0)),1,"""")"
[/font]

To add another condition, try...

Code:
[font=Courier New]Range("AA2").FormulaArray = "=IF(ISNUMBER(MATCH(1,($K$2:$K$393=Y2)*($O$2:$O$393=$D$1)[COLOR="Red"]*($P$2:$P$393=Z2)[/COLOR],0)),1,"""")"
[/font]

Additional conditions can be added, as desired. Of course, the more conditions you have, the less efficient the formula is going to be. You could convert the formula results to values. Or, if the formulas need remain in place, a helper column could be used.
 
Last edited:
Upvote 0
I found this example, but dont know how to make it have multiple conditions.

This is from the following:
http://www.mrexcel.com/forum/showthread.php?t=495131


If IsNumeric(Application.Match(Cells(i, "B"), Worksheets("EMP List").Range("A:A"), 0)) = True Then
If Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:G"), 7, 0) = "" Then
Cells(i, "H").Value = "n/a"
Else: Cells(i, "H").Value = Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:K"), 11, 0)
End If
End If
 
Upvote 0
I found this example, but dont know how to make it have multiple conditions.

This is from the following:
http://www.mrexcel.com/forum/showthread.php?t=495131


If IsNumeric(Application.Match(Cells(i, "B"), Worksheets("EMP List").Range("A:A"), 0)) = True Then
If Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:G"), 7, 0) = "" Then
Cells(i, "H").Value = "n/a"
Else: Cells(i, "H").Value = Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:K"), 11, 0)
End If
End If

I don't think you can adapt the above code to return the desired result. Have you tried the solution I offered?
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top