How to align and merge matching values, from various columns, in excel - excel

I have had some success matching data from various columns and creating a new data output. Here is what I typically start with;
COL A COL B COL C COL D
ITEM VALUE ITEM VALUE2
---- ---- ---- ----
A 1 B 100
B 2 A 200
C 3 F 300
G 4 E 400
H 5 C 500
J 6 M 600
And I can achieve this result using VLOOKUP;
COL E COL F COL G
ITEM VALUE VALUE2
---- ---- ----
A 1 200
B 2 100
C 3 500
G 4
H 5
J 6
But what I'm really after is this: both matching AND merging;
COL E COL F COL G
ITEM VALUE VALUE2
---- ---- ----
A 1 200
B 2 100
C 3 500
E 400
F 300
G 4
H 5
J 6
M 600
I'm punching a tad above my weight class with this one, so any help would be greatly appreciated.

With something like:
=COUNTIF(A:A,C2)
in a column and copied down you should get indication of which items are not already present in ColumnA. Sort with C:D on that basis and simply copy the items associated with 0 to ColumnA and their values to ColumnD, then sort and apply your VLOOKUP.

The following is based on: http://www.get-digital-help.com/2009/05/25/create-a-drop-down-list-containing-only-unique-distinct-alphabetically-sorted-text-values-using-excel-array-formula/#comment-74005
It's a great site for clever use of Excel formulas and does a good job of explaining the monster formulas below, creating dynamic named ranges, and how to work with array formulas. Look at it!
My solution is not quite as elegant as I'd like but it works. So, you'll need to create some named ranges.
One for the items in COL A (e.g. "Items1") and one for the items in COL C (e.g. "Items2")
In COL G we'll have another List "AllItems1". In COL H we'll have another List "AllItems2". You'll need to make a named range of "AllItems1" too.
The array formula in COL G is:
=IFERROR(IFERROR(INDEX(Items1,MATCH(0,IF(MAX(NOT(COUNTIF($G$1:$G1,Items1))* COUNTIF(Items1,">"&Items1)+1))=(COUNTIF(Items1,">"&Items1)+1),0,1),0)),INDEX(Items2,MATCH(0,IF(MAX(NOT(COUNTIF($G$1:$G1,Items2))*(COUNTIF(Items2,">"&Items2)+1))=(COUNTIF(Items2,">"&Items2)+1),0,1),0))),"")
Which is a mouthful. This cascades through each list (i.e. Items1 and Items2) and gives you a non-repetitive sorta alphabetized list of the items in "Items1" and "Items2".
COL G is really just an intermediate step to get us to COL H. I haven't found a way to combine two lists without doing this step. Let me know if you find a better way.
To get a non-repetitive AND alphabetized list of the items we put the following array formula in COL H:
=IFERROR(INDEX(AllItems1,MATCH(0,IF(MAX(NOT(COUNTIF($H$1:$H1,AllItems1))*(COUNTIF(AllItems1,">"&AllItems1)+1))=(COUNTIF(AllItems1,">"&AllItems1)+1),0,1),0)),"")
Then we do VLOOKUP s off of "AllItems2".
Put the following VLOOKUP in COL I :
=IFERROR(VLOOKUP($H2,$A$2:$B$7,2,0),"")
And put the following VLOOKUP in COL J:
=IFERROR(VLOOKUP($H2,$C$2:$D$7,2,0),"")
Of course, you could make "AllItems2" a named range also and use that in the VLOOKUP s.
I think that gets you what you want.

Related

Need help inputting data in excel columns from other columns

If I had data in rows A to E as seen below in the table. Some of the values can be NA. IN column F if i wanted to input data from columns A to E in a way that if data in A exists use that otherwise if data in B exists use that otherwise until column E. If none of them have any values return NA. I would like to automate this where somewhere I just specify the order for example A, B, C, D and E OR A, C, E, D, B and the values in F update according to the reference table
Reference : C - B - A - E - D
a
b
c
d
e
f
3
4
3
2
2
7
1
7
NA
1
4
2
4
2
2
4
2
2
Use FILTER() with # operator.
=#FILTER(A2:E2,A2:E2<>"","NA")
For dynamic array approach (spill results automatically), try-
=BYROW(A2:E7,LAMBDA(x,INDEX(FILTER(x,x<>"","NA"),1,1)))

How to create a one to many relationship?

The title may be confusing/misleading; I'm frankly having trouble trying to say what I need in a concise manner.
I have 2 lists of distinct values in Excel.
List A:
1
2
3
List B:
C
D
E
I need to create a sheet that shows a one to many relationship where List A is the 'One' and list B is the 'Many'. So the result would be something like :
Ouput:
1 C
1 D
1 E
2 C
2 D
2 E
3 C
3 D
3 E
The results are not concatenated and are in their own cols/rows. Any suggestions?
Assuming list 1 is in A1:A3, list to is in B1:B3. Then in D1 put :
=IF(CEILING(ROW()/ROWS($A$1:$A$3),1)>ROWS($A$1:$A$3),"",INDIRECT("A"&CEILING(ROW()/ROWS($A$1:$A$3),1),TRUE))
and in E1 :
=IF(CEILING(ROW()/ROWS($B$1:$B$3),1)>ROWS($B$1:$B$3),"",INDIRECT("B"&IF(MOD(ROW(),ROWS($B$1:$B$3))=0,ROWS($B$1:$B$3),MOD(ROW(),ROWS($B$1:$B$3))),TRUE))
and drag both downwards.
Idea : Use row() to 'guide' how the which cell will indirect() address to. You can test the given mod() and ceiling function separately to 'examine' how the pattern works. [do ask if you didn't get it.] (:
please share if it works/not.

Excel Formula comparing two columns

Below is a sample of the data I have. I want to match the data in Column A and B. If column B is not matching column A, I want to add a row and copy the data from Column A to B. For example, "4" is missing in column B, so I want to add a space and add "4" to column B so it will match column A. I have a large set of data, so I am trying to find a different way instead of checking for duplicate values in the two columns and manually adding one row at a time. Thanks!
A B C D
3 3 Y B
4 5 G B
5 6 B G
6 8 P G
7 9 Y P
8 11 G Y
9 12 B Y
10
11
12
11
12
I would move col B,C,D to a separate columns, say E,F,G, then using index matches against col A and col B identify which records are missing.
For col C: =IFERROR(INDEX(F:F,Match(A1,E:E,0)),"N/A")
For col D: =IFERROR(INDEX(G:G,Match(A1,E:E,0)),"N/A")
Following this you can filter for C="N/A" to identify cases where a B value is missing for an A value, and manually edit. Since you want A & B to be matching here col B is unnecessary, final result w/ removing col B and C->B, D->C:
A B C
3 Y B
4 N/A N/A
5 G B
6 B G
7 N/A N/A
Hope this helps!

Vlookup doesn't work with column of string

I have 4 columns, containing 2 columns of names and 2 columns of values, as below. I need to update Column B with value in K, if the name1 = name2. Both name columns are formatted as text, and values columns are formatted as numeric.
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A A 123
B B 456
C X 000
D Y 000
E Z 000
F C 789
I insterted the following vlookup in the first row of column B, but it returns the name in column A.
=VLOOKUP(A4,J2:J22890,K2:K22890)
I'm expecting to have the following result:
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A 123 A 123
B 456 X 000
C 789 B 456
D Y 000
E Z 000
F C 789
Am I using vlookup a the wrong way? or is it due to the fact that I'm looking up strings??
I think it should be
=VLOOKUP(A4,J2:K22890,2,0)
1.First parameter is the value you are looking for,
2.second one is the range (it can be multiple columns, with the referenced data in the most-left column of the selection),
3.followed by the column's number where the records should be retrieved from,
4.and lastly a flag (1 or 0) if you would like to accept similar results (1) or exact matches only (0)
Since I can't edit the post because it's not enough characters and I can't comment because I don't have enough rep...
=VLOOKUP(A4,$J$2:$K$22890,2,0)
This is Alex's post with absolute references for the lookup table array.

Excel: Arrange Rows to Match Another Row

I have a database with a column A with some values, and then 2 additional columns: Column B contains a bunch values that will match the ones in column A, but are not in order. I also have a Column with information that pertains to that specific row, amnd would like it to stay in 'sync' with column B. For example:
| A | B | C |
1 3 A
2 1 F
3 2 D
4 5 R
5 4 P
I'd like a way to sort it so my result would be:
| A | B | C |
1 1 F
2 2 D
3 3 A
4 4 P
5 5 R
Is there a way to do this?
If possible, if there is no match, delete the row?
In Excel 2007/2010,
simply select the cell with the "B" in it and go to the Data tab along the top and click on the A to Z button which is near the middle of the data tab. As long as B & C are adjacent columns, they will sort according to your needs. Please Note, Column A must not be adjacent to the other 2, otherwise you would run through the same procedure above but you would highlight columns B and C and perform the same sort button steps. If it gives you a Sort Warning, click the "Continue with the Current Selection" radio button and OK.

Resources