How to validate and combine the two excel vlookup column results to one column

vbvba

New Member
Joined
May 25, 2012
Messages
34
Hi Guys,

I have two vlookup formulas in two columns of a sheet which validates the value whether it is "Pass" or "fail" from another sheet of the same workbook.

Here are the below 2 formulas :-

1) =IF(VLOOKUP(BY2&G2&BG2,Sheet2!A:I,9,0)>=BV2,"Pass","Fail")


2) =IF(VLOOKUP(BY2&G2&BG2&CB2,Sheet2!B:J,9,0)>=BV2,"Pass","Fail")

I would like to combine the two formulas using AND or OR operator to one column, however when i evaluate the formula using AND or OR operator i receive #N/A error from 2nd formula.
Kindly help me in correcting the below formula

=IF(OR(VLOOKUP(BY2&G2&BG2,Sheet2!A:I,9,0)>BV2,IF(VLOOKUP(BY2&G2&BG2&CB2,Sheet2!B:J,9,0)>=BV2,"Pass","Fail")),"Pass","Fail")

Also I have to run the formula using below code please help me in the same :-

Code:
Sub runtheformula()

Dim RowNo As Long


'update formulas
RowNo = Sheet1.Range("A1048576").End(xlUp).Row


Sheet1.Range("CI2:CI" & RowNo).FormulaR1C1 =

 "=IF(VLOOKUP(RC[-4]&RC[-73]&RC[-21],Sheet2!C1:C8,8,FALSE)>=RC[-6],""Pass"",""Fail"")"


Sheet1.Range("CI2:CI" & RowNo).Value = Sheet1.Range("CI2:CI" & RowNo).Value


Sheet2.Visible = xlSheetVeryHidden


MsgBox "Validation done"

:)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
try the below formula:

=IF(OR(IFERROR(VLOOKUP(BY2&G2&BG2,Sheet2!A:I,9,0),"")>=BV2,IFERROR(VLOOKUP(BY2&G2&BG2&CB2,Sheet2!B:J,9,0),"")>=BV2),"Pass","Fail")
 
Upvote 0
Hi,

Thanks for the reply
When I try the formula I get all the values from top to bottom as Pass even though it is Fail
Can I attach the excel file or do you have any other formula ?

Thanks,
 
Upvote 0

Forum statistics

Threads
1,216,113
Messages
6,128,905
Members
449,477
Latest member
panjongshing

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