Loop through all matched values in EXCEL - excel

I have 2 tables, A and B
table B has columns, department and name
And table A has several fields, in particular the names of the employers that work for the Sales Department.
I need to create a new column in table A that checks if a name has been added in table B. The logic is if(name is matched to the names column of table B and the department= sales, then put 'OK', if not put 'NO'). The match function is fine, I am having trouble checking the value of the cell to the left of the column name i table B to check the department associated with the name. Can anyone help me? The tables are:
Table A
Name | New Column
Table B
Department | Name
I have come up with a way of using INDEX(MATCH()) to get the value of the cell next to the matched one. The issue is that a name for example can be repeated many times thoguh out table B. I need excel to look through all the matched names and check the value of the cell to the left until the value of the cell to the left = "Sales"

Table A
Name | New Column
New Column Formula
=If(iserror(Vlookup(Table A Name&"Sales",Table B DepAndName,1,0)),"No","Ok")
Table B
Department | Name | DepAndName
DepAndName Formula
=Name&Department

Related

Excel Index Match syntax question. getting a #N/A

I starting to get the concept of how Index and Match are supposed to work, but confused as to why this formula does not work.
I have 4 user sheets with tables in use, combining data from 3 into one. This is my current setup, which is working well so far.
Sheet1 "tblClickers" (export from phishing report):
Column A = Email
Column B/C = First/Last Name
Column N = phish failure data
Sheet2 "TblAD_US" (AD Export):
Column A = Title
Column C = Name
Column E = Email
Column F = Department #
Sheet3 "TblComb": combination sheet listing relevant data from other three.
Column A = "=tblAD_US[title]"
Column B = "=tblAD_US[Name]"
Column D = "=tblAD_US[EmailAddress]"
Column E = "=tblAD_US[Department]"
Column K = "=INDEX(tblClickers[Failures],MATCH([#[Email Address]],tblClickers[Email Address],0))"
Sheet4 "TblAD_Depts" (report listing department heads):
- column c = Department #
- Column D = Department head
I now want another column in Sheet 3 that lists the matching department head (sheet4/columnD) associated with the departments of each user. The data point I will match on is the Department# listed in Sheet 2/3 and Sheet 4.
I tried using the same formula syntax as I did for Clickers, but I'm getting a #N/A error.
=INDEX(TblAD_Depts[Department Head],MATCH([#Department],Tbl_Am_Depts[Department],0))
Where am I getting mixed up here? Do I need to reference the original data source for "Department#" in sheet 2 or can I "reference the reference" in sheet3?
tl;dr, want a new column L in Sheet 3. Values returned will be column D from Sheet 4, using Column E in sheet 3 and Column C in sheet 4 to match on.
Okay, (#JvdV) had it figured out. Even though I selected each column for "Department" and changed the format to [Number], one column was still listed incorrectly.
For some reason, Column C in Sheet 4 had each "Number Stored as Text". I'll just do a [Text to Column] and call it a day!
Thanks!

How to VLOOKUP an Excel Table in another Excel sheet

I am trying to VLOOKUP a value in an Excel Table and get the value from another Excel Table in another sheet.
the first table is called PRODUCTS and the second one is called PRODUCT DETAILS
In PRODUCTS I have:
GTIN-13 | SKU | NAME | PRICE
In PRODUCT DETAILS I have:
GTIN-13 | SKU | NAME | GW | NW
From PRODUCT DETAILS I am trying to Vlookup SKU from PRODUCTS and get the GTIN-13 value into PRODUCT DETAILS
GTIN-13 (PRODUCT DETAILS): =VLOOKUP([#SKU],PRODUCTS,1,)
But formula return #N/A.
I can't understand where I am mistaken
In PRODUCTS table, move SKU column to the leftmost of the table. So column order will be as below:
SKU | GTIN-13 | NAME | PRICE
In PRODUCT DETAILS table, use the below formula:
=VLOOKUP([#SKU],PRODUCTS,2,FALSE)
In this VLOOKUP formula, the number 2 indicates that you are trying to fetch the value from 2nd column (i.e. GTIN-13 is the 2nd col in PRODUCTS) when there is a match on SKU in the first column (VLOOKUP always tries to match values in the first column of your search range) in PRODUCTS.
Hope that helps!
VLOOKUP only works when the common column in both the table is on the left side of the desired values column.
You can just change the SKU column position to the left of GTIN-13 column and your formula will work fine.
Now if you don't want to tamper with the data tables and want more powerful lookup function, then you can use INDEX & MATCH functions.
INDEX takes 3 values - INDEX(Table, Row, Column)
MATCH takes 3 values - MATCH(Cell, Column, [-1, 0, 1]) ---- Here 0 is used to find the exact match
Now if you combine the both functions you can replace the Row of INDEX with the MATCH function.
It will be like this - INDEX(Table, MATCH(Cell, Column, 0), Column)
My formula in the sheet is INDEX(I:J, MATCH(D2, J:J, 0), 1)
Here I have used 1 as the Column of INDEX because I wanted the values of GTIN-13.

Excel 2010: Vlookup Name from one column & Count and return data from another column

Hoping someone can help me here. :)
I have two columns of data in Worksheet 1:
COLUMN A = NAME (EG. TOM)
COLUMN C = TYPE OF QUERY (FAX, TEL, EMAIL, MAIL)
I would like to have in Worksheet 2:
COLUMN A = NAME (EG TOM)
COLUMN B = A COUNT OF HOW MANY FAXES TOM HAS
COLUNN C = A COUNT OF HOW MANY TELEPHONES TOM HAS
COLUMN D - A COUNT OF HOW MANY EMAILS TOM HAS
COLUMN E = A COUNT OF HOW MANY MAILS TOM HAS
If anyone can help me that would be great.
Thanks guys
You can use a pivot table. In sheet 1, click into the data table, then click Insert > Pivot table.
Drag the Name field to the rows. Drag the query type field to the columns.
Drag the Namie field again, this time to the Values area, where it will turn into a count.
Now you see a count of query types for each name in a matrix.
Use countifs instead if you really want to use formula. A pivot table would be the best way to go though.
eg for column B, row 1 on sheet 2:
=COUNTIFS(Sheet1!A:A, A1, Sheet1!C:C, "FAX")

Copying specific values to a separate column

I have an excel sheet with 6 columns A,B,C,D,E,F,G
The sheet gives an overview of states and cities.
My problem is that column C (region) contains names of states and cities.
Every time the name of a state is displayed, cities will follow beneath in this same column.
Column E contains values state or city.
If column C has value name of a state E has value state, if it has a name of a city E has value city
What I want is every city followed by a separate column:Statename.
I am looking for a function when E has value state the value in C 'Name of the state will be copied to a separate column Statename behind each cityname
Something like this, perhaps?
IF(B2="state", "", IF(B1="state",A1,C1))

Identify matching numbers and then imput a value from a different column

I have two sheets, Sheet1 and Sheet2. Sheet1 has a list of company names in column A, Revenue in column B and a unique number identifier in column D (also seen as "unique #forAAA in Sheet2). In Sheet2, I pulled a list from Hoovers, and the format comes up something like below (so this format should not be changed).
Column A B C D
Company Name Place Type of Comp Revenue
1 AAA US HQ 10.0 M
2 unique #forAAA
3 BBB India Branch 5.0 M
4 unique #forBBB
What I'd like to do is match the unique number for each company between Sheet1 and Sheet2 and then put the revenue # from Sheet2 into column B of Sheet1 which corresponds to the correct #. I'm pretty lost here, so any help or ideas would be great. Thanks for your help!
Because the unique identifier is on a different row than the result to be returned, you can use a variation using INDEX and MATCH:
=INDEX(Sheet2!D:D, MATCH(D2, Sheet2!A:A, 0)-1)
INDEX will return the value within range Sheet2!D:D on row MATCH(D2, Sheet2!A:A, 0)-1.
MATCH(D2, Sheet2!A:A, 0) will give you the row number where the unique ID is found, then -1 to get the row number of the revenue amount.
EDIT: As per comment, to remove the M, you can use this:
=TRIM(SUBSTITUTE(INDEX(Sheet2!D:D, MATCH(D2, Sheet2!A:A, 0)-1),"M",""))
I would put the unique value in a column inserted before A (would be the new column A) instead of putting it below each row. Then, in the other sheet I'd put the VLOOKUP like this:
=VLOOKUP(D2,Sheet2!A:E,5,0)
That should return the value in column E (column D before the column insertion, i.e. revenue for the unique company identifier).
Note that the third argument in the vlookup function is the number of the column you want to be retrieved, so the range defined in the second argument (Sheet2!A:E) should contain that column.

Resources