Excel: Create Custom Sheet 2 Based on Data in Sheet 1 - excel

I have two sheets in a spreadsheet. Each sheet has a first column with common values (however they are not sorted the same and they are not all there in each sheet).
What I'm trying to do, if possible, is put a formula in sheet 2, where, if column 1 is a match for sheet 1, copies selective data from certain columns in that same row in sheet 1, to certain columns in sheet 2.
Example:
Sheet 1 has a heading setup and sample data row like this:
Title | Day of Week | First | Last
Supervisor | Wednesday | Mike | Jones
Sheet 2 has a heading setup and sample data row like this:
Title | Surname | Weekday
Supervisor | (empty cell) | (empty cell)
After running the mystery formula I'm looking for, placed in the 2 empty cells above, sheet 2 should match on the Supervisor key in sheet 1 and copy in data I have specified into each column, such as:
Title | Surname | Weekday
Supervisor | Jones | Wednesday
(In this case I have told it to map the "day of week" column to weekday, and map the "last" column to "surname").
I hope this is easy/possible??? Help???

VBA is not necessary. You can use a simple VLOOKUP:
=VLOOKUP(cell to look-up,
range where you want to look up the values (first column *must* contain the keys to look-up) including all columns that you want to retrieve,
the position of the column to be retrieved relative to the first column specified in argument 2,
0 (specifies you want an exact match))
For example:
=VLOOKUP(A1, Sheet1!$A$1:$D$150, 2, 0) ' Retrieves the 2nd column matching criteria in A1
Please notice, however, that you need your keys to be unique. Matching information based on the title seems a bit odd since it is likely there will be more than one person assigned to a certain role. For example, there may be more than 1 supervisor.

Use INDEX and MATCH (better than VLOOKUP).
I suggest renaming your headers so they match on both sheet.
Sheet 1 should be :
Title | Weekday | First Name | Surname
In sheet 2, cell B2 type in
=INDEX(Sheet1!$A:$D,match($A2,Sheet1!$A:$A,0),match(B$2,Sheet1!$1:$1,0))
You can drag and drop it in column C as well, it will work since you are using two MATCH functions with the cells properly anchored.

Related

Excel IF/THEN/VLOOKUP Nested Formula

I have two tabs in an excel file. Sheet 1 and Sheet 2. I have been working on a nested IF/THEN/OR/AND formula in excel that needs to do the following:
In Sheet 1, I need to make sure that two columns - Name 1 and Name 2 - match. If they do not match, I need to make sure that Name 2 matches to a Name column in Sheet 2.
Formula must - If Name 1 and Name 2 in Sheet 1 match, then YES, else NO. If NO, then VLOOKUP Name from Sheet 2 and Match with Name 2 in Sheet 1. If there is a match then display YES, else NO.
So far I have two separate columns that check for this. The first uses an exact statement to match the two name columns in sheet 1. The second does a vlookup to see if the name appears in the second sheet. I need this in one cell formula if possible and I am not sure how to do so without splitting.
+----------+----------+--+--+----------+
| Sheet 1 | | | | Sheet 2 |
+----------+----------+--+--+----------+
| Column 1 | Column 2 | | | Column 1 |
| Name 1 | Name 2 | | | Name |
+----------+----------+--+--+----------+
You will need to adjust the formula below for your sheet names and ranges, but this is a formula that will check column A against column B and if not the same, will check column B against a vlookup table. It also lets you know if there was not a match found in the vlookup table instead of just giving the error code #N/A
=IF(A3=B3,"Columns Match",IFERROR(VLOOKUP(B3,Sheet2!A4:B14,2,FALSE),"No Match Found In Vlookup"))

Display in Sheet1 newest entries from Sheet2 to Sheetn in excel

I have an excel file which has an arbitrary number of sheets. From Sheet2 to Sheetn the structure is the same:
| A | B | C | D |
------------------------------
| Date | Name | Value | Type |
| Date | Name | Value | Type |
However, these rows are not sorted by the date, so the 1st row of each sheet is not guaranteed to be the newest date.
The first sheet has one row for each sheet and it should be updated to include the most recent entry in each sheet.
For example, if we have 4 Sheets, then Sheet 1 will have 4-1=3 rows which will be: the row with the newest date of Sheet 2, the row with the newest date of Sheet 3, and the row with the newest date on Sheet 4.
A file equals a thousand words, so you can download the excel file here and see what I need.
I've actually figured out a solution. I'm guessing it's significantly far from the best one, but since I'm by no means an excel person, the fact that it works is enough for me.
For other non-excel people who just need to achieve this without learning excel, here's how I did it:
=INDEX(MySheetName!$A$2:$G$10000,(MATCH(MAX(MySheetName!$C:$C),MySheetName!$C:$C,0)-1),COLUMNS(MySheetName!$A$1:A1))
Replace "MySheetName" on its 4 occurrences to the actual Sheet name of each of your excel's sheets.
Replace Columns 'A to G' on the INDEX to the columns you want to retrieve.
Replace Column C:C on the MATCH to the column you want used to retrieve the row number using its MAX()
Remember to span the formula to multiple columns, as many as the maximum columns that the sheet you reference has.
What I'd like to improve now is to make it able to span multiple rows as well, which for me it would mean that it would automatically reference all the columns of the next excel sheet. For now, one needs to manually replace "MySheetName".
The "10000" also looks really bad, but I don't know how to many sure that it will get the Max() over all rows. I'll never fill more than 100 rows on each sheet, so 10000 seems safe.

How do I add information to a neighbouring cell if there is specific text in an existing cell?

I'm working with 311 datasets. I have monthly spreadsheets for a specific municipality with over 10,000 entries per sheet.
The columns in the datasheet provide details such as call description, time of call, date of call and the City Ward the call originated from.
Problem is that the spreadsheets only give the Ward number, i.e.:
creation_date | ward | call_description | call_type
01-Jan-15 | Ward 4 | Calendar to be Mailed | Solid Waste Collection
I have a separate spreadsheet that assigns shape coordinates for the respective ward:
OBJECTID | DESCRIPTIO | WARD_NUM | WARDNUMTEX | SHAPE_Length | SHAPE_Area
4 | XXXXX |4 | Ward 4 | 19871.78596 | 16418739.66
What I want to do is create a formula that when it sees Ward 4 in the one column, the SHAPE_Length and SHAPE_Area are assigned in the corresponding cell in the next column.
This is a job for vlookup().
Assuming that your tab with the shape coordinates is called wardinfo and that it starts in cell A1. Also assuming that your datasheets data starts in A1, meaning the ward number is in column B, your vlookup() to get the Shape_Length will be:
=vlookup(B1, wardinfo!C:F, 3, false)
And to get the Shape_Area:
=vlookup(B1, wardinfo!C:F, 4, false)
Just stick those in a new column on the same row and then copy them down.
You can use a VLOOKUP formula ( https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1 ), something like
=VLOOKUP(B2,Sheet2!D:F,2,FALSE)
Where B2 is the cell in the ward column your looking up, D:F is the range of columns you're using in the other sheet as a database (D is the column in the other sheet that has the Ward 4 index string, the rest of the columns you need should be to the right of that), and 2 is the column number that has the value you want to use as the result of the lookup (in that example, D is column 1, E would be column 2, probably SHAPE_Length and F would be column 3, probably SHAPE_Area).
You would put the formula a second time specifying column 3 for the second piece of info. The formula would go in the cell where you want the answer.

Excel multi column lookup

I am unsure how to Google this one. I have a table that looks like the below
Last Name | First Name | Team A | Team B | Team C
Smith | John | X | |
Doe | Jane | | X |
This would be the main sheet. The names in this sheet are divided into other sheet depending on what department they are in. Those sheets are setup in the same formats with the same columns. If the people in the main sheet are marked with an X in one of the columns I would like that same column marked in marked in the department sheets.
Your best bet might be to create a hidden column A where the value is a combination of column B and column C on all of your tabs. You could then use the standard VLOOKUP wrapped in an IFERROR clause.
For example,
=IFERROR(VLOOKUP(A1,Sheet1!A:F,3,False),"")
The IFERROR handles the instance that you may have a name on a sub tab not on the main tab. It returns blank instead of #N/A. The VLOOKUP is checking the value in A1 to what is in A1 on your main tab. A1 would be the combination of First and Last. The VLOOKUP would need to be in each of your team columns shifting the column returned number in each VLOOKUP.

Find two matching rows and display data from the thirt one (Excel)

So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel

Resources