Comparing two columns in excel sheet and if match writing adjucent cell value in new cell - excel-formula

i have 3 columns
A B C D
11H 3HI xyz
2AB 2CD dfd
3HI 11H 123
I am struggling for the formula through which i can compare column A & B and if matched the adjucent cell value should be written in column D. For example
A B C D
11H 3HI xyz 123
2AB 2CD dfd ---
3HI 11H 123 xyz.
my column consisting of 43000 cells vertically. i have to compare all these values and write the results using excel. Please help me with this.
Thanks in advance.

The formula you're after is:
=VLOOKUP(A1,$B$1:$C$3,2,FALSE)
Here's an image. Always show your attempts. We tend to help those who have attempted to help themselves more.
However, if the dashes are a must instead of the #N/A in D2, then this is the formula
=IFERROR(VLOOKUP(A3,$B$1:$C$3,2,FALSE),"---")

Related

How to find and replace from a List in Excel

Not using VBA but just simple excel, can anyone help me find a solution to this problem? Would greatly appreciate it!
I have a list of Names in Sheet 1 like below
-
A
1
sp_abc_Rick
2
sp_abc_Jabba_the
3
sp_abc_Dany
4
sp_random_Rick
5
sp_random_Jabba_the
6
sp_random_Dany
7
sp_constant
8
sp_ripley_art_Dany
9
sp_ripley_art_Jabba_the
10
sp_wakeup
I have a list of Mapping Table in Sheet 2 like below
-
A
B
1
Rick
Morty
2
Jabba_the
Hutt
3
Dany
Dragon
I wish to have a result in Sheet 1, in column B, like below
-
A
B
1
sp_abc_Rick
sp_abc_Morty
2
sp_abc_Jabba_the
sp_abc_Hutt
3
sp_abc_Dany
sp_abc_Dragon
4
sp_random_Rick
sp_random_Morty
5
sp_random_Jabba_the
sp_random_Hutt
6
sp_random_Dany
sp_random_Dragon
7
sp_constant
sp_constant
8
sp_ripley_art_Dany
sp_ripley_art_Dragon
9
sp_ripley_art_Jabba_the
sp_ripley_art_Hutt
10
sp_wakeup
sp_wakeup
To give you a context of the number of rows. Sheet 1 will be bigger with more than 1000 rows. Sheet 2 (Mapping Table) is constant set of rows. Currently it is about 100 rows.
You can use a formula like shown below using LOOKUP(), SEARCH() with SUBSTITUTE()
• Formula used in cell B1
=IFERROR(SUBSTITUTE(A1,LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$D$1:$D$3),
LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$E$1:$E$3)),A1)
There you go. There may have other better solution. This is what I got.
All in column B.
=IFERROR(CONCAT(MID(A1,1,MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)-1),INDIRECT(CONCAT("sheet2!b", MATCH(MID(A1, MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE), LEN(A1)), Sheet2!$A$1:Sheet2!$A$300, 0)))),A1)
Break down is as follow;
Let's start put things from Column C onward.
Column C, to find the index of the first capital letter from the text.
ref: http://dailydoseofexcel.com/archives/2007/02/21/find-position-of-first-capital-letter-in-a-string/
=MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)
Column D, cut the name part by using upper case letter index from column C, sp_abc_Jabba_the -> Jabba_the
=MID(A1, C1, LEN(A1))
Column E, search row number from Sheet2 by matching Column D's name with Sheet 2's Column A, this will get matching row number from Sheet2.
=MATCH(D1, Sheet2!$A$1:Sheet2!$A$300, 0)
Column F, get Sheet2's Column B value by the row number from Column E.
=INDIRECT(CONCAT("sheet2!b", E1))
Column G,
Cut "sp_abc_" from "sp_abc_Rick"
Concat "sp_abc_" with Column F's "Morty".
If there is any error, use Column A value as default.
. <- this dot is intentional. please ignore.
=IFERROR(CONCAT(MID(A1,1,C1-1),F1),A1)
Try:
Formula in B1:
=BYROW(A1:A10,LAMBDA(a,LET(b,TEXTBEFORE(a&"|","_"&A12:A14&"|",-1),IFERROR(CONCAT(IF(b&"_"&A12:A14=a,b&"_"&B12:B14,"")),a))))
The concatenation with a "|" would assert we only replace values when at the exact end of the input. Just in case there would be a stray (for example) 'Rick' somewhere before the end.

Excel - Extracting substring after a character contained in a string

I am trying to extract partial string contained within a cell after a certain character in the string.
I have a formula which can do this
=RIGHT(C10,LEN(C10)-SEARCH(":",C10))
But let's say the location of C10 cell isn't exactly known within the C column, and a way to locate it is by searching for a keyword in column D and then extracting the partial string using the above formula to a cell next to the keyword (column E).
I hope this makes sense.
Ex)
Column C
John: 1234 Alphabet Street
Claire: 3456 Diamond Street
Tim: 333 Laugh Lane
Bo: 5555 Great Neck Street
Grace: 777 Whiteside Blvd
Column D
John:
Claire:
Bo:
Thank you.
You could use:
=TRIM(SUBSTITUTE(VLOOKUP(D1&"*",C:C,1,0),D1,""))
This approach should work for you. First, modify the formula as below for the first row in E (i.e., E2)
=IF(ISTEXT(D2),RIGHT(C2,LEN(C2)-SEARCH(":",C2)),"No address found.")
In order to apply this formula throughout for the column triplets C, D and E do the following: Click on the top-left corner of column 'C', hold and drag the cursor towards right to include columns D and E and now drag all the way down to the last row of C, D and E. Now, the formula is automatically applied to all the rows viz. C, D and E.

Lookup Function Excel

I am working on a lookup function and I cant seem to make it work. I am looking up a value from one worksheet into another. The issue I am having is that some names in the excel sheet iI am looking up are not spaced at the same as the other sheet.
For example instead of John Davis, the lookup sheet might have the name as JohnDavis. Or Peter Lee Thomas might be Peter LeeThomas. So my looking function is failing because of this.
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH('Raw Data'!B2,Sheet3!A:A,0)))
Can you please advice on the best way around this? My Lookup sheet is Sheet3
Okay, if for example your data looked like this:
A B C D
Some Text 1 2 SomeText3
Som e Text 2 3 Some Text 2
So meText 3 4 SomeTex t1
Lookup formula in column D would be:
=INDEX($B$1:$B$3,MATCH(SUBSTITUTE(C1," ",""),SUBSTITUTE($A$1:$A$3," ",""),0))
Make sure to apply this formula with Ctrl + Shift + Enter.
The result will look as expected:
A B C D
Some Text 1 2 SomeText3 4
Som e Text 2 3 Some Text 2 3
So meText 3 4 SomeTex t1 2
One solution would be to create another column Sheet3, in this example B, to remove all spaces, like this:
In cell B2 (and copied down): =substitute(A2,"","")
Then alter your lookup to alter its data similarly and to search in this space eliminated row B:
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH(substitute('Raw Data'!B2," ",""),Sheet3!A:A,0)))

Highlight cells based on the value of cells in another column

I have this problem as noted below:
Column A = Part number
Column B = Quantity
Column C = Part number
Column D = Quantity
Using conditional formatting, I would like to highlight if the combination of Part number and Quantity in Column A and B is different to the combination of Part number and Quantity in Column C and D.
Eg:
Col A Col B Col C Col D
1 1111 2 1112 5
2 1112 3 1111 2
3 1131 5 1112 5
4 1122 3 1131 2
To do this, I'd like to set up a couple of 'helper' columns (say E & F) by concatenating Column A & B, C & D.
So essentially, I'd like to take the information from the helper columns E & F, but use conditional formatting to highlight the cell in column B and D.
From the example above, cell B3 and D4 would be highlighted.
Is this possible, and if not, is there are simple alternative? (I don't mind using a macro if need be).
I would use COUNTIFS
For B1:B4
=COUNTIFS($C$1:$C$4,A1,$D$1:$D$4,"<>"&B1)
and for D1:D4
=COUNTIFS($A$1:$A$4,C1,$B$1:$B$4,"<>"&D1)
In case you even want to skip the helper columns, you could format A1 with =$A1&$B1<>$C1&$D1 and copy the format to any cells in you want to be highlighted (even to your helper columns).

Excel concatenate the column based on other column

I have data in excel like this
A B C
p1 ABC 2
p2wt ABC 3
p3 EFG 1
p3wtke EFG 1
p9r EFG 2
I'm trying to sum up C column if B column has same data and concatenate A column data. And data looks like
A B C
p1-p2wt ABC 5
p3-p3wtke-p9r EFG 4
I tried using =SUMIFS(C1:C5,A1:A9,B1) but it is giving #value, and how do i concate A? I tried Excel concatenate, but is A2>A1 in this link is for number fields?
Use a helper column.
In D1 put:
=IF(B1<>B2,A1,A1&"-"&D2)
Then copy/drag down the data set.
The in another column create a list of the unique values in column B. I put mine in G.
Then in F1 I put:
=VLOOKUP(G1,B:D,3,FALSE)
And in H1 I put:
=SUMIF(B:B,G1,C:C)
Then copies/dragged down.

Resources