How to check if value/string in one row of Table 1 is present in Table 2? - excel

I want to check if a value or text string in a given row in Table 1 is also present in a given column in Table 2. Of course I could do this column by column in Table 1 but with about 50 columns I don't really want to. My data looks something like this:
Table 1
1 aaa bbb ccc
2 ddd eee fff
3 ggg hhh iii
Table 2
1 bbb
2 xxx
3 ccc

You could use an array formula:
=SUM(IF(COUNTIF(Sheet2!$A$1:$A$3,$A1:$C1)>0,1,0))
Press CTRL-SHIFT-ENTER after entering it as opposed to ENTER
This will tell you how many exist in the list on sheet2 for each row in sheet 1

Related

TEXTJOIN per table line based on heading

I need to create a string per row line that includes all elements that are present in that row but displaying the corresponding heading column text, while not representing (in the string) the element that is the label of the row. Explaining...
Consider the following table:
AAA
BBB
CCC
DDD
AAA
1
1
1
BBB
1
1
1
BBB
1
CCC
1
1
I expect the following result (for each table row):
Column A
BBB, DDD
AAA, CCC
DDD
Take notice that in the first row (which stand for element "AAA") that element does not appear in the string - same for "BBB" in the second line and "CCC" in the last line. For that same reason, the third line has an empty string as result.
In order to solve this, I'm creating a new table with each of the table heading element (that's not the row element) and then do a TEXTJOIN with ", " as separator. As follows:
AAA
BBB
CCC
DDD
AAA
BBB
DDD
=TEXTJOIN(", ";TRUE;B2:B5)
BBB
AAA
CCC
=TEXTJOIN(", ";TRUE;C2:C5)
BBB
=TEXTJOIN(", ";TRUE;D2:D5)
CCC
DDD
=TEXTJOIN(", ";TRUE;E2:E5)
Now, for sure it may be possible to do this without the need to create this extra table - or maybe to create such a table inline in the formula ?
You can use this formula:
=LET(
rH,B1:E1,
cH,A2:A5,
d,B2:E5,
BYROW(cH,LAMBDA(r,
TEXTJOIN(",",TRUE,
FILTER(rH,(rH<>r)*(CHOOSEROWS(d,ROW(r)-1)=1),"")
))))
It filters - per data-row - the header-row and returns only those values from the header row that don't match the rows first cell and have a 1 in the according column of the data row.
EDIT:
As per your comment - a one-liner that you have to drag down:
=LET(rH,$B$1:$E$1,cH,A2,d,B2:E2,
TEXTJOIN(",",TRUE,
FILTER(rH,(rH<>cH)*(d=1),"")
)
)
In this case you don't need the BYROW- part

Excel case insensitive sum product

I am trying to do a sum product to compare a cell to a column in another sheet and bring the value in another column associated to the match.
Using :
=SUMPRODUCT(Item_mst!$H$1:$H$4,--(A1=Item_mst!$B$1:$B$4))
sheet 1
Item
A
1 aaa
2 bbb
3 ccc
Item_mst
Item Qty
B H
1 aaa 20
2 AAA 10
3 AAA 20
4 AAA 20
The above formula gives me aaa/AAA = 60 while the correct value answer I expect is 70. Its not picking up the item when the qty is different and the case doesnt match.
SUMIFS would be a better solution
But, to answer the actual Q, try
=SUMPRODUCT(Item_mst!$D$1:$D$4,--(LOWER(H1)=LOWER(Item_mst!$B$1:$B$4)))

Comparing two columns in excel, inserting blank rows moving associated data

I have a large set of data in excel that needs to be matched by column. Specifically, the data currently looks like:
Column 1 Column 2 Column 3
1 1 aaaa
2 3 bbbb
3 4 cccc
4
Ideally, I want the data to look like:
Column 1 Column 2 Column 3
1 1 aaaa
2
3 3 bbbb
4 4 cccc
I've looked at different ways of comparing Column 1 and Column 2 (similar to this), but haven't found a good way to a) insert the blank space where column 1 and 2 don't match and b) also attach the data in column 3.
Any help would be greatly appreciated! Thanks!
If you want / can use directly Excel:
In the cells of Col "D" put this formula:
=IFERROR(MATCH(A2;$B$2:$B$8;);"")
In the cells of Col "E" put this formula:
=IF(D2<>"";INDEX($B$2:$C$8;D2;1);"")
In the cells of Col "F" put this formula:
=IF(D2<>"";INDEX($B$2:$C$8;D2;2);"")
Copy and paste for all the cells.
The good think it's that it's autoupdated... Or when finish copy and paste with value.

Find value from one cell, copy value from cell near to that cell and paste it to another sheet

I have 2 sheets with different values. I need to find a value from one cell.sheet1 in sheet2 and copy value from nextcell_in_the_same_row.sheet1 to nextcell_in_the_same_row.sheet2.
It is very difficult to explain let look at the example bellow.
E.g.
Before
first sheet:
A B
1 aaa 123
2 bbb 456
3 ccc 789
4 ddd 122
second sheet:
A B
1 aaa
2 ada
3 cca
4 ccc
After
first sheet:
A B
1 aaa 123
2 bbb 456
3 ccc 789
4 ddd 122
second sheet:
A B
1 aaa *need to find value in the first sheet and copy value from B2 because aaa in A1*
2 ada *value does not exist in the first sheet so copy nothing*
3 cca *not need to copy because no value in the first sheet*
4 ccc *need to copy the value from B3*
Thank you so much!
Use a VLOOKUP along with an IFERROR.
=IFERROR(VLOOKUP(A1, Sheet1!A:B, 2, 0), "")
This will do what you described (well described, by the way!) in your question. Drag the formula down in Sheet2 till the bottom.
VLOOKUP takes the value of A1 in sheet 2 (no sheet reference because the value is in the same sheet as the formula) and looks it up in column A of Sheet1.
It returns the second value (hence why 2) of the table selected in the formula (column A is 1, column B is 2).
The 0 tells the VLOOKUP to look for exact matches. You don't need approximate match here.
And IFFERROR is there in case VLOOKUP doesn't find anything (like with ada) and instead of giving #N/A, returns an empty cell, "".

Find Results in excel copy the rows to another sheet

I need some help copying data from one excel worksheet to another. For example:
Sample Data
__A__B___C
1 aaa bbb ddd
2 bbb ccc eee
3 ccc fff rrr
4 ccc fff ttt
5 ddd eee ggg
6 aaa ddd eee
7 bbb fff hhh
8 eee eee eee
So for the above records if I do a 'CTRL + F' and search to find All 'eee' the results will show 6 instances in C2, B5, C6, A8, B8, C8
Now I want to copy the whole of rows 2,5,6 and 8 to another worksheet.
This worked for me... a simple solution:
Select/highlight the data you want to search
Press ctrl +h for Replace
Enter the string you want to find in "Find What".
Select "Replace with" Format, then Format > Fill and choose a background fill, doesn't matter what color. Then click [Replace All].
Then choose on the Excel menu > Data > Sort on "Cell Color",
Order (the color you chose from step 4 above) and then "On Top" or "On Bottom" - whatever you want, click [Ok].
Now all the data you wanted is all in one block of rows. Copy and paste to another worksheet as required.
To achieve what you need please do the following (assuming your data is located in columns A:C starting row 2, i.e. there are headers):
Type in D2 (additional column): =IF(OR(A2:C2="eee"),1,0), but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Autofill formula as required.
Add filter to the whole A:D range.
Apply filter to column D for value 1.
Copy entire filtered columns A:C and paste anywhere - only filtered rows will be copied.
Sample file: https://www.dropbox.com/s/qscwbf5kbnwi5pa/Filtering3Columns.xlsx
I think what you are looking for is called VLOOKUP just take the Excel-help, theres everything explained
The easiest way I found was this: Using the option "Sort & Filter" located in the right upper corner. Then you can filter any column by any criteria you like. By doing that only the filtered rows appear on the spread sheet (the rest are still there but just hidden). From there you can easily copy and paste the entire rows.

Resources