Match multiple criteria between 2 workbooks and return "text" if there is no match

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
915
Office Version
  1. 365
Platform
  1. Windows
I will be building a simple Macro in an excel workbook that the user can open and run.
The user will have to have the first Workbook open when they run the macro so I can reference it as active workbook (for this example I will call it Workbook1, this workbook name can change) .
What the Macro will do is put a formula in column E workbook1.
It is the formula (in yellow area) that I need assistance with...for now.

1594229659025.png


What I need the formula to do is if A2,B2,C2 and D2 (on Active workbook1) all match I:J (on the last sheet of Workbook:Database),
leave cell blank. If they do not match, the result would be the word "flag"

A4&"|"&B4&"|"&C4&"|"&D4 MATCH I:I&"|"&J:J&"|"&K:K&"|"&L:L

I am also curious if the formula can reference the last sheet in a workbook without knowing the sheet name?
as the formula in Workbook 1 will be referencing the last created sheet in workbook: Database
*if not I will need to consider a work around for this, a code that determines the last sheet name and references it to a cell and then have that formula reference that cell??


Additional Question Relating to the above:

Note as per the picture:
The first row the status changed
the second row, nothing changed
The third row, the quantity changed
The 4th row, was new data entirely

Now if the first question wasn’t complicated enough: could we go one step further and add IF conditions?
Instead of just flagging the changes with the word "flag" could it be modified to display text as follows?:
If change is between column A and I: "Date Change"
If change is between column B and J: "Qty Change"
If change is between column C and K: "Status Change"
If change is between column D and L: "Part # Change"
If change is multiple: "multiple"

If this is too complicated then just the match between 2 workbooks with the word "flag" is fine and I will re-post the 2nd question.

Thank you to anyone who can help. I know how to do an index match with multiple criteria however this is a bit more involved.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
With formula, I can't find a way to know what the last sheet of a book is.
If you are going to use a macro to get the sheet, it would be convenient to create the macro to do the whole process. If you agree, I help you with the whole macro.
 
Upvote 0
That sounds like a good plan. I will re-post regarding that later. For now I still need a formula so lets just say we know the sheet names and then worry about obtaining the sheet names via macro later.

Is this possible?

Thank you again for all of your help!
 
Upvote 0
Is an array formula:

varios 08jul2020.xlsm
ABCDE
1DateQtyStatusPartFlag
203-jun5ClosedAE2256Flag
304-jun3ClosedTX952 
405-jun2OpenYU834Flag
506-jun2OpenCF5542Flag
Hoja3
Cell Formulas
RangeFormula
E2:E5E2=IF(ISNUMBER(MATCH(A2&"|"&B2&"|"&C2&"|"&D2,[Database.xlsx]Sheet1!$A$2:$A$20&"|"&[Database.xlsx]Sheet1!$B$2:$B$20&"|"&[Database.xlsx]Sheet1!$C$2:$C$20&"|"&[Database.xlsx]Sheet1!$D$2:$D$20,0)),"","Flag")
Press CTRL+SHIFT+ENTER to enter array formulas.


I do not recommend comparing against the entire column: (MATCH I: I & "|" & J: J & "|" & K: K & "|" & L: L)
because it is an array formula and that would cause a bad performance in your sheet.
 
Upvote 0
This works perfectly.

Is there a way to add text depending where there is no match? (My second question above)

Note as per the picture:
The first row the status changed
the second row, nothing changed
The third row, the quantity changed
The 4th row, was new data entirely

Instead of just flagging the changes with the word "flag" could it be modified to display text as follows?:
If change is between column A: "Date Change"
If change is between column B: "Qty Change"
If change is between column C: "Status Change"
If change is between column D: "Part # Change"
If change is multiple: "multiple/new"

Thank you for all of your help
 
Upvote 0
Several times.

Currently I am trying your formula out on the real workbook but it is giving me an error:

1594316261252.png


The modified formula for the real workbooks is:

=IF(ISNUMBER(MATCH(A6&"|"&F6&"|"&G6&"|"&J6,[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020!$F$10:$F$5000&"|"&[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020!$H$10:$H$5000&"|"&[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020!$A$10:$A$5000&"|"&[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020!$G$10:$G$5000,0)),"","Flag")

Any idea why I am getting this error?
 
Upvote 0
last created sheet in workbook: Database
Your book was called "database" with no spaces in between.
Your book is now called "COMPANY NAME - Master forecast - INC" with blanks in between.
Then you have to add Apostrophe:

=IF(ISNUMBER(MATCH(A6&"|"&F6&"|"&G6&"|"&J6,
'[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020'!$F$10:$F$5000&"|"&
'[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020'!$H$10:$H$5000&"|"&
'[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020'!$A$10:$A$5000&"|"&
'[COMPANY NAME - Master forecast - INC.xlsx]JULY 2020'!$G$10:$G$5000,0)),"","Flag")
 
Upvote 0
Thank you very much!

Is there a way to modify the formula further regarding what I mentioned above? (Flagging the type of change)
 
Upvote 0
Is there a way to modify the formula further regarding what I mentioned above? (Flagging the type of change)

I still do not know, you did not answer my questions from post #6.
Could you give an example with more data.

The part number is a unique id, that is, we can use it as a key.
In the "database" book does it appear once or several times?
 
Upvote 0

Forum statistics

Threads
1,223,250
Messages
6,171,036
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