Comparing two columns

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
I have two columns where in Column A (starting in row 7) I pasted/transposed the table headers from an old worksheet. In column B7 I pasted the Table headers from a new version of the table.

I want to have one formula in column C that would tell me

is the value in A and B the same (it exists in both tables in the same row). Then 1
Value is in A and B but not the same row. Then 2
Value is in A but not in B. Then 3
Value is in B but not in A. Then 4

ABExample of formula results (or something like this)
Example1Example11
Example2Example42,4
Example3Example23,2
Example5Example63,4
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I don't quite follow your use of the term "value". Does "value" refer to something specifically, or merely the presence of something in the referenced cell? For example, the last line in your sample table (Example 5 / Example 6)...a value is in A and a different value is in B, so why does the desired result not include "2" also?
 
Upvote 0
I don't quite follow your use of the term "value". Does "value" refer to something specifically, or merely the presence of something in the referenced cell? For example, the last line in your sample table (Example 5 / Example 6)...a value is in A and a different value is in B, so why does the desired result not include "2" also?
Yeah, I find that example a bit confusing too. I think it has been simplified too much, to the point that we don't really understand what the actual data really looks like and what the expected result should look like.

gheyman,
Can you post an example using more realistic data, so we can get a better feel of what the data actually looks like, and what you want the actual result to look like?
 
Upvote 0
I re-read the original post and think I understand...the desired result in column C is supposed to be a pair of results. The first of the pair of results uses the column A value as the baseline to determine whether it produces a 1, 2, 3, or 4. Then the second of the pair of results uses the column B value as the baseline to determine whether it produces a 1, 2, 3, or 4. But if that is the case, then the first line should be 1,1 rather than 1...unless another rule is invoked to deliver a single result if both are the same. All of the other results then make sense.
 
Upvote 0
Like this maybe?
MrExcel_20240305.xlsx
ABC
7OldNewResult
8Ex1Ex11
9Ex2Ex42,4
10Ex3Ex23,2
11Ex5Ex63,4
Sheet3
Cell Formulas
RangeFormula
C8:C11C8=TEXTJOIN(",",,IF(A8=B8,1,IF(ISNUMBER(MATCH(A8,$B$8:$B$11,0)),2,3)),IF(A8=B8,"",IF(ISNUMBER(MATCH(B8,$A$8:$A$11,0)),2,4)))
 
Upvote 0
Solution
Like this maybe?
MrExcel_20240305.xlsx
ABC
7OldNewResult
8Ex1Ex11
9Ex2Ex42,4
10Ex3Ex23,2
11Ex5Ex63,4
Sheet3
Cell Formulas
RangeFormula
C8:C11C8=TEXTJOIN(",",,IF(A8=B8,1,IF(ISNUMBER(MATCH(A8,$B$8:$B$11,0)),2,3)),IF(A8=B8,"",IF(ISNUMBER(MATCH(B8,$A$8:$A$11,0)),2,4)))
Thank you
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,122,998
Members
449,092
Latest member
masterms

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