Find data in two lists and compare with each other - excel

this is my first time posting here, but I didn't know where else to go.
I have two lists in excel, both of them with similar data but in different orders, each one has 3 columns (prefix (A, D), suffix (B, E) and data (C, F)).
Let's say list 1 is in columns A, B and C; and list 2 in D, E, F.
Each element in column C has an equal one in column F, but in different order and also, the previous two columns (prefix and suffix) may or may not have different values from their counterpart.
I want to do this (I guess it has to be done with macros but I don't really know, I'm not too much of an expert with excel), I want to take each element from column C (data) and find it's equivalent in column F, after that, I want to compare their prefix and suffix, and maybe paint it red when they're different and green when they're the same.
Is this possible? (and not too much of a hassle?)
If you didn't understand something, please reply and I'll be glad to try and explain better.

You can do it without macros by using conditional formatting
(There is an excellent write up of conditional formatting at Debra Dalgleish's site here. In xl2003 conditional formatting is accessed via the Format .. Conditional Formatting menu.)
If your data to be matched was in A1:F10 then these two formulas can be used to
match column C against F and return the position in F where column C has a match
compare the values in column D and E in this position to the respective values in columns A and B
format column A and B for valid matches using =A1=INDEX(D$1:D$10,MATCH($C1,$F$1:$F$10,0))
format column A and B for invalid matches using =A1<>INDEX(D$1:D$10,MATCH($C1,$F$1:$F$10,0))
In the sample below I have added these two conditional formats to cells A1:B10 in xl2010
A valid match is green
Invalid matches are red
Non matches are not formatted
So A1 and B1 are green as they match D2 (Mr) and E2 (Jones) for a common value of 1 in C1 and F2
So A3 is green as it matches D1 (Father) for 10 in C3 and F1, but B3 is red as E1 does not contain "wang"

I'd do the following:
Move column F before columns D and E (now D is the data, E is the prefix and F is the suffix)
Create three new columns G, H and I with the formulas:
=vlookup(C1, D:F, 2, 0)
=vlookup(C1, D:F, 3, 0)
=and(G1=A1,H1=B1)
Place conditional formatting on column I, with red for FALSE and green for TRUE.
The first step is necessary because VLOOKUP will look for the value in the first column of data.
On the second step, you will match the column C with column F (now moved to D) and obtain the corresponding prefix and suffixes. The next formula compares both and returns TRUE or FALSE if they both match.
You could combine all three formulas in one, if needed.

Related

How to conditional format a range based on the values of 3 columns

First of all, I'm sorry for my lack of terms and poor knowledge on the subject. I tried to gather code fragments but no luck. The problem is as follows and I'd very much appreciate it if you could give me some pointers.
I have 3 columns (A B and C) with some values. Then, i have 2 columns D and E which i need to conditional format based on A B and C values.
The conditions are the following:
D-> If D1 is between A1+B1 and A1+C1 Then D1 stays in black color
Else D1 appears in red color
E-> If E1 is between B1 and C1 then E1 stays in black color
Else E1 appears in red color
The process then repeats for D2, D3, etc. Same goes for E.
There will be different sheets with the same code and i probably will be adding several rows to some of them, which might tamper with the definition of the range in A B and C. Also, for each day, I'll be adding two sets of columns (ex: first day I'll add D and E, then F and G, etc). Can i double loop the code on D column for odd numbers? and for even numbers regarding E column?
These are my main questions.
Select column D (entire column)
Add a new conditional formatting rule with the formula below and format it red
=NOT(AND($D1>$A1,$D1<$B1,$D1<$C1))
Select column E (entire column)
Add a new conditional formatting rule with the formula below and format it red
=NOT(AND($E1>$B1,$E1<$C1))
Note that "between" means the borders (in column A, B, C) are excluded if you want to include them you need to chang > to >= and < to <=.
You can also add a conditional formatting with VBA:
With ThisWorkbook.Worksheets("Sheet1").Columns("D").FormatConditions.Add(Type:=xlExpression, Formula1:="=NOT(AND($D1>$A1,$D1<$B1,$D1<$C1))")
.Font.Color = -16776961
.Font.TintAndShade = 0
End With
But note that the formula in Formula1 must be localized. That means if you plan to run this on a non-english Excel then this formula must be converted to this localized non-english formula.

formatting a cell in a column if it is an exact match to a cell in a separate column

I want to put a strike-through in column G if it matches the cell next to it in column F (column G is a verification of F). I found a couple formats but for some reason certain cells are not crossing off even though they match while other cells are.
Right now I have formatted G to
=COUNTIF(G:G,F1)
I have also tried
=COUNTIF(F:F,G1)
for column G as well and still some cells will cross off while others don't
A much simpler formula is:
=G1=F1
provided your Applies to range starts from G1.

Find matching value and show that value and its corresponding values

I have two columns B and F, both containing many email addresses. I have a current statement that searches for all matching emails in B and if the email exists in F, it outputs "Y", if no match, the output is "N".
Here is the code: =IF(ISNA(MATCH(F2,B$2:B$50,0)),"N","Y")
How do I alter my statement so that when a match between F and B is found the output value in B and the corresponding row values in A, C, and D are all shown in a new column to the right of F?
If I think I understand the question, you want to copy the information in columns A/C/D when you return True / Y from your initial formula.
You should be able to use a simple if statement to solve this.
=IF(E1="Y", A1, "")
=IF(E1="Y", C1, "")
=IF(E1="Y", D1, "")
Here we check if the value in E (I am assuming this is your output column) has returned as a Y. If it does then it will copy the text from A/C/D.
Given that F is your email to match column, B is your array column (list of all emails), and A/C/D are all columns to copy. You can add absolute column references to quickly copy while keeping E as your reference column.

Concatenate multiple rows of Column B until column A contains X then, loop again

enter image description here
I need to do this in excel and I do know how to do this with python etc, but it has to be done in excel either VBA or formula (best option).
Column A, contains a "W" character.
Column B, contains a "abc" cell that will be the same everywhere (The other rows won't be the same).
Column C, I am concatenating all cells in column B before column A hits a "W" value.
I want to achieve some sort of a formula in a single or multiple steps that will allow me to concatenate all B column rows until column A has a "W". The concatenation must happen in same row as "abc" in column B, but paste on column C.
Thank you in advance
If you can use column D (as an intermediate step) as well as C, set C2 to
=IF(A2="W",D2,"")
and set D2 to
=B2&IF(A3="W","",";;"&D3)
then copy column C and D down as far as necessary.

Highlighting a cell in one column when matching value found anywhere in a second column

Column B is where data is going to be entered.
Column I has a list of data that is predefined.
I want column I's data to be highlighted when the data is found anywhere in column B. Example:
A B C D E F G H I J
---------------------------------------------
3 1
2 2
7 3
So the cells in column I containing 2 and 3 would be highlighted because found in Column B at some point.
Please try selecting ColumnI, HOME > Styles - Conditional Formatting - New Rule..., Use a formula to determine which cells to format, Format values where this formula is true:
=COUNTIF(B:B,I1)>0
choose your formatting, OK, OK.
Use conditional formating with
=isna(match($i1,$b$1:$b$3,0))
as the condition for cells that don't match (the zero is important as it means exact matches only)
... but
=countif($b$1:$b$3,$i1)=0
will do the same thing, while
=countif($b$1:$b$3,$i1)>0
is a condition for matches

Resources