Question

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.

Was it helpful?

Solution

I'd do the following:

  1. Move column F before columns D and E (now D is the data, E is the prefix and F is the suffix)

  2. 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)

  3. 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.

OTHER TIPS

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"

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top